home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / misc / 290 / sheet20.doc < prev   
Encoding:
Text File  |  1988-10-10  |  225.8 KB  |  6,073 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.                                SHEET -- FOR ATARI ST
  27.                  A BASIC interpreter in a spreadsheet environment
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.              Atari, 520 ST and ST are trademarks of Atari Corporation
  50.                     GEM is trademark of Digital Research, Inc.
  51.               Lotus 123 is trademark of Lotus Development Corporation
  52.  
  53.  
  54.  
  55.              Copyright (C) 1988, Chor-ming Lung. All rights reserved.
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.                                  Table of Content
  76.                                  ________________
  77.                                                  
  78.  
  79.  
  80.      Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   1
  81.  
  82.      Disclaimer  . . . . . . . . . . . . . . . . . . . . . . . . . . . .   1
  83.  
  84.      Requirements  . . . . . . . . . . . . . . . . . . . . . . . . . . .   1
  85.  
  86.      Introduction  . . . . . . . . . . . . . . . . . . . . . . . . . . .   2
  87.  
  88.                                PART I -- TUTORIAL  . . . . . . . . . . .   3
  89.      Example 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   4
  90.      Example 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   9
  91.      Example 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  11
  92.      Example 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  13
  93.      Example 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  15
  94.      Example 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  16
  95.      Example 7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  18
  96.      Example 8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  19
  97.      Example 9 . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  20
  98.  
  99.                        PART II -- Spreadsheet operations . . . . . . . .  22
  100.  
  101.      MENU SELECTIONS . . . . . . . . . . . . . . . . . . . . . . . . . .  23
  102.           Desk . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  23
  103.                About SHEET . . . . . . . . . . . . . . . . . . . . . . .  23
  104.           File . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  23
  105.                New    N  . . . . . . . . . . . . . . . . . . . . . . . .  23
  106.                Load   L  . . . . . . . . . . . . . . . . . . . . . . . .  23
  107.                Load WKS  . . . . . . . . . . . . . . . . . . . . . . . .  23
  108.                Load PART . . . . . . . . . . . . . . . . . . . . . . . .  23
  109.                Save   S  . . . . . . . . . . . . . . . . . . . . . . . .  23
  110.                Save WKS  . . . . . . . . . . . . . . . . . . . . . . . .  23
  111.                Save PART . . . . . . . . . . . . . . . . . . . . . . . .  23
  112.                Print  P  . . . . . . . . . . . . . . . . . . . . . . . .  23
  113.                Quit   Q  . . . . . . . . . . . . . . . . . . . . . . . .  23
  114.           Sheet  . . . . . . . . . . . . . . . . . . . . . . . . . . . .  23
  115.                Erase . . . . . . . . . . . . . . . . . . . . . . . . . .  23
  116.                Defaults  . . . . . . . . . . . . . . . . . . . . . . . .  23
  117.                Options . . . . . . . . . . . . . . . . . . . . . . . . .  24
  118.                Dates . . . . . . . . . . . . . . . . . . . . . . . . . .  24
  119.           Row/Col  . . . . . . . . . . . . . . . . . . . . . . . . . . .  25
  120.                Insert  I . . . . . . . . . . . . . . . . . . . . . . . .  25
  121.                Delete  D . . . . . . . . . . . . . . . . . . . . . . . .  25
  122.                Col widths  . . . . . . . . . . . . . . . . . . . . . . .  25
  123.           Cells  . . . . . . . . . . . . . . . . . . . . . . . . . . . .  25
  124.                Reformat  R . . . . . . . . . . . . . . . . . . . . . . .  25
  125.                Erase     E . . . . . . . . . . . . . . . . . . . . . . .  25
  126.                Copy      C . . . . . . . . . . . . . . . . . . . . . . .  25
  127.                Move      M . . . . . . . . . . . . . . . . . . . . . . .  25
  128.                Adjust    A . . . . . . . . . . . . . . . . . . . . . . .  25
  129.           Graph  . . . . . . . . . . . . . . . . . . . . . . . . . . . .  25
  130.           Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  26
  131.  
  132.  
  133.                                        - i -
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.      MOVING AROUND . . . . . . . . . . . . . . . . . . . . . . . . . . .  27
  145.  
  146.      EDITING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  28
  147.           Types of cell entry  . . . . . . . . . . . . . . . . . . . . .  28
  148.                Formula . . . . . . . . . . . . . . . . . . . . . . . . .  28
  149.                Constant  . . . . . . . . . . . . . . . . . . . . . . . .  28
  150.                Statement . . . . . . . . . . . . . . . . . . . . . . . .  28
  151.                Command . . . . . . . . . . . . . . . . . . . . . . . . .  28
  152.                Text  . . . . . . . . . . . . . . . . . . . . . . . . . .  28
  153.           Rules for constructing formula . . . . . . . . . . . . . . . .  29
  154.           Cell input . . . . . . . . . . . . . . . . . . . . . . . . . .  30
  155.                Move the editing cursor . . . . . . . . . . . . . . . . .  30
  156.                Modify your input . . . . . . . . . . . . . . . . . . . .  30
  157.                Terminate your input  . . . . . . . . . . . . . . . . . .  30
  158.                Miscellaneous operations  . . . . . . . . . . . . . . . .  30
  159.           Modify a cell  . . . . . . . . . . . . . . . . . . . . . . . .  31
  160.           Editing direction  . . . . . . . . . . . . . . . . . . . . . .  31
  161.  
  162.      CUSTOMIZED DISPLAY  . . . . . . . . . . . . . . . . . . . . . . . .  32
  163.           Change column width  . . . . . . . . . . . . . . . . . . . . .  32
  164.           Default display format . . . . . . . . . . . . . . . . . . . .  33
  165.           Display format:  . . . . . . . . . . . . . . . . . . . . . . .  33
  166.           Block  . . . . . . . . . . . . . . . . . . . . . . . . . . . .  34
  167.           De-select blocks . . . . . . . . . . . . . . . . . . . . . . .  34
  168.           Change display format  . . . . . . . . . . . . . . . . . . . .  35
  169.  
  170.      COPY AND MOVE . . . . . . . . . . . . . . . . . . . . . . . . . . .  36
  171.           Relative and Absolue cell reference  . . . . . . . . . . . . .  37
  172.  
  173.      ERASE CELLS . . . . . . . . . . . . . . . . . . . . . . . . . . . .  38
  174.  
  175.      INSERT AND DELETE . . . . . . . . . . . . . . . . . . . . . . . . .  39
  176.           Row/Column selection . . . . . . . . . . . . . . . . . . . . .  39
  177.  
  178.      LOAD, SAVE AND PRINT  . . . . . . . . . . . . . . . . . . . . . . .  40
  179.           File extension . . . . . . . . . . . . . . . . . . . . . . . .  40
  180.           Load . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  40
  181.           Save . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  40
  182.           Load PART  . . . . . . . . . . . . . . . . . . . . . . . . . .  40
  183.           Save Part  . . . . . . . . . . . . . . . . . . . . . . . . . .  41
  184.           Lotus files  . . . . . . . . . . . . . . . . . . . . . . . . .  41
  185.           Print  . . . . . . . . . . . . . . . . . . . . . . . . . . . .  41
  186.  
  187.                              PART III -- SHEET BASIC . . . . . . . . . .  43
  188.  
  189.      Cells and Variables . . . . . . . . . . . . . . . . . . . . . . . .  44
  190.           Cell reference with dimension  . . . . . . . . . . . . . . . .  44
  191.           Variables  . . . . . . . . . . . . . . . . . . . . . . . . . .  44
  192.           Cell reference with variables  . . . . . . . . . . . . . . . .  44
  193.           String . . . . . . . . . . . . . . . . . . . . . . . . . . . .  45
  194.           String operators 
  195.           String operators . . . . . . . . . . . . . . . . . . . . . . .  45
  196.  
  197.      Flow control Statements . . . . . . . . . . . . . . . . . . . . . .  47
  198.           IF .. THEN .. ELSE ..  . . . . . . . . . . . . . . . . . . . .  47
  199.           GOTO . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  47
  200.           GOSUB .. RETURN  . . . . . . . . . . . . . . . . . . . . . . .  47
  201.  
  202.                                       - ii -
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.           LOOP .. EXIT IF .. ENDLOOP . . . . . . . . . . . . . . . . . .  47
  214.           FOR .. NEXT  . . . . . . . . . . . . . . . . . . . . . . . . .  48
  215.           RUN  . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  48
  216.  
  217.      I/O Statements  . . . . . . . . . . . . . . . . . . . . . . . . . .  49
  218.           REDIRECT TO  . . . . . . . . . . . . . . . . . . . . . . . . .  49
  219.           PRINT statement  . . . . . . . . . . . . . . . . . . . . . . .  49
  220.  
  221.      Miscellaneous statements  . . . . . . . . . . . . . . . . . . . . .  51
  222.           SAVE SCREEN  . . . . . . . . . . . . . . . . . . . . . . . . .  51
  223.           RESTORE SCREEN . . . . . . . . . . . . . . . . . . . . . . . .  51
  224.           WAIT . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  51
  225.           DEFINE . . . . . . . . . . . . . . . . . . . . . . . . . . . .  51
  226.           MESSAGE  . . . . . . . . . . . . . . . . . . . . . . . . . . .  52
  227.  
  228.      Text files  . . . . . . . . . . . . . . . . . . . . . . . . . . . .  53
  229.           GET_FILE . . . . . . . . . . . . . . . . . . . . . . . . . . .  53
  230.           OPEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  53
  231.           CLOSE  . . . . . . . . . . . . . . . . . . . . . . . . . . . .  53
  232.           INPUT #n . . . . . . . . . . . . . . . . . . . . . . . . . . .  54
  233.           PRINT #n . . . . . . . . . . . . . . . . . . . . . . . . . . .  54
  234.  
  235.      Worksheet commands  . . . . . . . . . . . . . . . . . . . . . . . .  55
  236.           COPY . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  55
  237.           MOVE . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  55
  238.           ERASE  . . . . . . . . . . . . . . . . . . . . . . . . . . . .  55
  239.           REFORMAT . . . . . . . . . . . . . . . . . . . . . . . . . . .  55
  240.           SORT . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  56
  241.           SWAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  56
  242.  
  243.      Console commands  . . . . . . . . . . . . . . . . . . . . . . . . .  57
  244.           CLS  . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  57
  245.           CURSORON . . . . . . . . . . . . . . . . . . . . . . . . . . .  57
  246.           CURSOROFF  . . . . . . . . . . . . . . . . . . . . . . . . . .  57
  247.           VIDEOHIGH  . . . . . . . . . . . . . . . . . . . . . . . . . .  57
  248.           VIDEONORM  . . . . . . . . . . . . . . . . . . . . . . . . . .  57
  249.           GOTOXY . . . . . . . . . . . . . . . . . . . . . . . . . . . .  57
  250.           INKEY  . . . . . . . . . . . . . . . . . . . . . . . . . . . .  58
  251.           UNGET  . . . . . . . . . . . . . . . . . . . . . . . . . . . .  58
  252.           INPUT  . . . . . . . . . . . . . . . . . . . . . . . . . . . .  58
  253.  
  254.      Graphic commands  . . . . . . . . . . . . . . . . . . . . . . . . .  59
  255.           Setup commands . . . . . . . . . . . . . . . . . . . . . . . .  60
  256.                WINDOW  . . . . . . . . . . . . . . . . . . . . . . . . .  60
  257.                VIEWPORT  . . . . . . . . . . . . . . . . . . . . . . . .  61
  258.                SCALE . . . . . . . . . . . . . . . . . . . . . . . . . .  61
  259.                CLEAR . . . . . . . . . . . . . . . . . . . . . . . . . .  61
  260.                EXITGRAPH . . . . . . . . . . . . . . . . . . . . . . . .  61
  261.           Line/Dot commands  . . . . . . . . . . . . . . . . . . . . . .  62
  262.                ATTRIBUTE . . . . . . . . . . . . . . . . . . . . . . . .  62
  263.                LINE  . . . . . . . . . . . . . . . . . . . . . . . . . .  62
  264.                LINE_TO . . . . . . . . . . . . . . . . . . . . . . . . .  62
  265.                PLOT  . . . . . . . . . . . . . . . . . . . . . . . . . .  63
  266.                PLOT DATA . . . . . . . . . . . . . . . . . . . . . . . .  63
  267.                SPLINE  . . . . . . . . . . . . . . . . . . . . . . . . .  63
  268.           Turtlegraphics . . . . . . . . . . . . . . . . . . . . . . . .  64
  269.  
  270.                                       - iii -
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.                FORWARD . . . . . . . . . . . . . . . . . . . . . . . . .  64
  282.                TURN  . . . . . . . . . . . . . . . . . . . . . . . . . .  64
  283.                TURN_TO . . . . . . . . . . . . . . . . . . . . . . . . .  64
  284.           Axis command . . . . . . . . . . . . . . . . . . . . . . . . .  65
  285.                MARKX . . . . . . . . . . . . . . . . . . . . . . . . . .  65
  286.                MARKY . . . . . . . . . . . . . . . . . . . . . . . . . .  65
  287.                LABELX  . . . . . . . . . . . . . . . . . . . . . . . . .  65
  288.                LABELY  . . . . . . . . . . . . . . . . . . . . . . . . .  65
  289.           Text command . . . . . . . . . . . . . . . . . . . . . . . . .  66
  290.                PTEXT . . . . . . . . . . . . . . . . . . . . . . . . . .  66
  291.           Miscellaneous  . . . . . . . . . . . . . . . . . . . . . . . .  67
  292.                MOUSE_POS . . . . . . . . . . . . . . . . . . . . . . . .  67
  293.  
  294.      Tips on using SHEET BASIC . . . . . . . . . . . . . . . . . . . . .  68
  295.           Interrupt  . . . . . . . . . . . . . . . . . . . . . . . . . .  68
  296.           Using previous row format  . . . . . . . . . . . . . . . . . .  68
  297.           Error 
  298.           Error  . . . . . . . . . . . . . . . . . . . . . . . . . . . .  68
  299.           Multiple statements  . . . . . . . . . . . . . . . . . . . . .  68
  300.           Garbled screen . . . . . . . . . . . . . . . . . . . . . . . .  68
  301.           Adjust . . . . . . . . . . . . . . . . . . . . . . . . . . . .  68
  302.  
  303.      Appendix A BUILT-IN FUNCTIONS . . . . . . . . . . . . . . . . . . .  69
  304.           Math . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  69
  305.                General functions . . . . . . . . . . . . . . . . . . . .  69
  306.                     ABS  . . . . . . . . . . . . . . . . . . . . . . . .  69
  307.                     INT  . . . . . . . . . . . . . . . . . . . . . . . .  69
  308.                     FRAC . . . . . . . . . . . . . . . . . . . . . . . .  69
  309.                     FACT . . . . . . . . . . . . . . . . . . . . . . . .  69
  310.                     SQR  . . . . . . . . . . . . . . . . . . . . . . . .  69
  311.                     SQRT . . . . . . . . . . . . . . . . . . . . . . . .  69
  312.                Trigo & logarithm functions . . . . . . . . . . . . . . .  69
  313.                     SIN  . . . . . . . . . . . . . . . . . . . . . . . .  69
  314.                     COS  . . . . . . . . . . . . . . . . . . . . . . . .  69
  315.                     TAN  . . . . . . . . . . . . . . . . . . . . . . . .  69
  316.                     ASIN . . . . . . . . . . . . . . . . . . . . . . . .  69
  317.                     ACOS . . . . . . . . . . . . . . . . . . . . . . . .  69
  318.                     ATAN . . . . . . . . . . . . . . . . . . . . . . . .  69
  319.                     LOG  . . . . . . . . . . . . . . . . . . . . . . . .  69
  320.                     LN . . . . . . . . . . . . . . . . . . . . . . . . .  69
  321.                     EXP  . . . . . . . . . . . . . . . . . . . . . . . .  69
  322.                     RAD_DEG  . . . . . . . . . . . . . . . . . . . . . .  69
  323.                     DEG_RAD  . . . . . . . . . . . . . . . . . . . . . .  69
  324.                DATE functions  . . . . . . . . . . . . . . . . . . . . .  69
  325.                     DATE . . . . . . . . . . . . . . . . . . . . . . . .  69
  326.                     DAY  . . . . . . . . . . . . . . . . . . . . . . . .  69
  327.                     MONTH  . . . . . . . . . . . . . . . . . . . . . . .  69
  328.                     YEAR . . . . . . . . . . . . . . . . . . . . . . . .  69
  329.                Matrix functions  . . . . . . . . . . . . . . . . . . . .  69
  330.                     INVERSE  . . . . . . . . . . . . . . . . . . . . . .  69
  331.                     TRANSPOSE  . . . . . . . . . . . . . . . . . . . . .  69
  332.           Statistics . . . . . . . . . . . . . . . . . . . . . . . . . .  70
  333.                AVERAGE . . . . . . . . . . . . . . . . . . . . . . . . .  70
  334.                MEDIAN  . . . . . . . . . . . . . . . . . . . . . . . . .  70
  335.                STD . . . . . . . . . . . . . . . . . . . . . . . . . . .  70
  336.                VAR . . . . . . . . . . . . . . . . . . . . . . . . . . .  70
  337.                SQR_SUM . . . . . . . . . . . . . . . . . . . . . . . . .  70
  338.  
  339.                                       - iv -
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.           Miscellaneous  . . . . . . . . . . . . . . . . . . . . . . . .  70
  351.                MAX . . . . . . . . . . . . . . . . . . . . . . . . . . .  70
  352.                MIN . . . . . . . . . . . . . . . . . . . . . . . . . . .  70
  353.                SUM . . . . . . . . . . . . . . . . . . . . . . . . . . .  70
  354.                RAND  . . . . . . . . . . . . . . . . . . . . . . . . . .  70
  355.                IFF . . . . . . . . . . . . . . . . . . . . . . . . . . .  70
  356.                ISEMPTY . . . . . . . . . . . . . . . . . . . . . . . . .  70
  357.                TRUE  . . . . . . . . . . . . . . . . . . . . . . . . . .  70
  358.                FALSE . . . . . . . . . . . . . . . . . . . . . . . . . .  70
  359.                ALERT . . . . . . . . . . . . . . . . . . . . . . . . . .  70
  360.                COL_WIDTH . . . . . . . . . . . . . . . . . . . . . . . .  71
  361.                LAST_ROW  . . . . . . . . . . . . . . . . . . . . . . . .  71
  362.                LAST_COL  . . . . . . . . . . . . . . . . . . . . . . . .  71
  363.                SEARCH  . . . . . . . . . . . . . . . . . . . . . . . . .  71
  364.           Finance  . . . . . . . . . . . . . . . . . . . . . . . . . . .  71
  365.                Future growth . . . . . . . . . . . . . . . . . . . . . .  71
  366.                     GRATE  . . . . . . . . . . . . . . . . . . . . . . .  71
  367.                     GBASE  . . . . . . . . . . . . . . . . . . . . . . .  71
  368.                     GFUTURE  . . . . . . . . . . . . . . . . . . . . . .  71
  369.                Investment  . . . . . . . . . . . . . . . . . . . . . . .  71
  370.                     INVEST_PV  . . . . . . . . . . . . . . . . . . . . .  71
  371.                     INVEST_FV  . . . . . . . . . . . . . . . . . . . . .  72
  372.                     INVEST_INTEREST  . . . . . . . . . . . . . . . . . .  72
  373.                     INVEST_TERM  . . . . . . . . . . . . . . . . . . . .  72
  374.                Loan  . . . . . . . . . . . . . . . . . . . . . . . . . .  72
  375.                     LOAN_PAY . . . . . . . . . . . . . . . . . . . . . .  72
  376.                     LOAN_AMOUNT  . . . . . . . . . . . . . . . . . . . .  72
  377.                     LOAN_TERM  . . . . . . . . . . . . . . . . . . . . .  72
  378.                Withdraw  . . . . . . . . . . . . . . . . . . . . . . . .  72
  379.                     WDRAW_SAVE . . . . . . . . . . . . . . . . . . . . .  72
  380.                     WDRAW_AMOUNT . . . . . . . . . . . . . . . . . . . .  72
  381.                     WDRAW_TERM . . . . . . . . . . . . . . . . . . . . .  72
  382.                Deposit . . . . . . . . . . . . . . . . . . . . . . . . .  72
  383.                     DEPOSIT_FV . . . . . . . . . . . . . . . . . . . . .  72
  384.                     DEPOSIT_AMOUNT . . . . . . . . . . . . . . . . . . .  72
  385.                     DEPOSIT_TERM . . . . . . . . . . . . . . . . . . . .  72
  386.           String functions:  . . . . . . . . . . . . . . . . . . . . . .  72
  387.                FILENAME$ . . . . . . . . . . . . . . . . . . . . . . . .  72
  388.                BUF$  . . . . . . . . . . . . . . . . . . . . . . . . . .  72
  389.                MID$  . . . . . . . . . . . . . . . . . . . . . . . . . .  72
  390.                LEFT$ . . . . . . . . . . . . . . . . . . . . . . . . . .  73
  391.                RIGHT$  . . . . . . . . . . . . . . . . . . . . . . . . .  73
  392.                SPACE$  . . . . . . . . . . . . . . . . . . . . . . . . .  73
  393.                CHR$  . . . . . . . . . . . . . . . . . . . . . . . . . .  73
  394.                STR$  . . . . . . . . . . . . . . . . . . . . . . . . . .  73
  395.                VAL . . . . . . . . . . . . . . . . . . . . . . . . . . .  73
  396.                LEN:  . . . . . . . . . . . . . . . . . . . . . . . . . .  73
  397.                POS . . . . . . . . . . . . . . . . . . . . . . . . . . .  74
  398.  
  399.      Appendix B CONTROL KEYS . . . . . . . . . . . . . . . . . . . . . .  74
  400.           Non-editing  . . . . . . . . . . . . . . . . . . . . . . . . .  74
  401.           Editing  . . . . . . . . . . . . . . . . . . . . . . . . . . .  75
  402.  
  403.      Appendix C Program specification  . . . . . . . . . . . . . . . . .  75
  404.  
  405.      Appendix D Lotus and SHEET  . . . . . . . . . . . . . . . . . . . .  76
  406.  
  407.                                        - v -
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.      Appendix E Recalculation  . . . . . . . . . . . . . . . . . . . . .  77
  420.  
  421.      Appendix F FILE FORMAT  . . . . . . . . . . . . . . . . . . . . . .  78
  422.           Header for SHT . . . . . . . . . . . . . . . . . . . . . . . .  78
  423.           Cell contents for SHT format . . . . . . . . . . . . . . . . .  78
  424.           Header for PRT . . . . . . . . . . . . . . . . . . . . . . . .  78
  425.           Cell contents for PART format  . . . . . . . . . . . . . . . .  78
  426.  
  427.      Appendix G Problems . . . . . . . . . . . . . . . . . . . . . . . .  78
  428.  
  429.      Biorthym program  . . . . . . . . . . . . . . . . . . . . . . . . .  80
  430.  
  431.      Calendar program  . . . . . . . . . . . . . . . . . . . . . . . . .  82
  432.  
  433.      Roots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  84
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470.  
  471.  
  472.  
  473.  
  474.  
  475.                                       - vi -
  476.  
  477.  
  478.  
  479.  
  480.  
  481.  
  482.  
  483.  
  484.  
  485.  
  486.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  487.  
  488.      Preface:
  489.      ________
  490.                I have  used spreadsheet  programs for  quite a while. I feel
  491.           they are fantastic tools. I am quite familiar with Lotus  123. One
  492.           thing that  I feel  terrible is  its MACRO  language. It is not as
  493.           user-friendly as its display. I feel  that BASIC  is more powerful
  494.           and yet easier to use than MACRO.
  495.  
  496.                Thinking that  may be profitable to write a BASIC interpreter
  497.           in a spreadsheet environment,  I started  to write  the program on
  498.           Oct.  1987.  After  a  few  months'  struggle,  I have created the
  499.           program and named it SHEET.
  500.  
  501.                Making SHEET as shareware,  I uploaded  the first  version on
  502.           February 1988 to GEnie and CompuServe. Right now, SHEET can do not
  503.           only numerical calculation, but  also, graphic,  string operations
  504.           and text  files access. Its growth depends on you. If you like it,
  505.           please send me $25 or whatever you think  it is  worth. My address
  506.           is:
  507.  
  508.                                Mr. Chor-ming Lung
  509.                               330 Tremont St A-708
  510.                                 Boston, MA 02116
  511.                                      U.S.A.
  512.  
  513.                You can  also send  your comments or suggestions by Email. My
  514.           addresses are:
  515.                                    GEnie: LUNG
  516.                               CompuServe: 72740,40
  517.  
  518.                If you have access of GEnie, you can also leave  your message
  519.           on the bulletin board. It is Page 475, Category 2, Topic 28.
  520.  
  521.  
  522.      Disclaimer:
  523.      __________
  524.                I  have  made  every  effort  to  insure  the accuracy of the
  525.           program. However, there is no warranty  either express  or implied
  526.           for its uses.
  527.  
  528.  
  529.      Requirements:
  530.      ____________
  531.           * Atari 520 ST or 1040 ST with disk drive(s).
  532.           * Monochrome or color monitor.
  533.           * SHEETxxx.PRG, CALC.RSC and SHEET.CFG on the same directory. (xxx
  534.             is the version number of SHEET. Currently, it  is SHEET20.PRG or
  535.             version 2.0)
  536.           * You must know how to operate with GEM.
  537.           * Some BASIC programming experience is desirable if you want to
  538.             use SHEET BASIC effectively.
  539.  
  540.  
  541.  
  542.  
  543.  
  544.  
  545.  
  546.                                      Page 1
  547.  
  548.  
  549.  
  550.  
  551.  
  552.  
  553.  
  554.  
  555.  
  556.  
  557.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  558.  
  559.      Introduction:
  560.      ____________
  561.  
  562.           Thank you  for using  SHEET. SHEET is a combination of spreadsheet
  563.      and BASIC. The  spreadsheet  functions  and  commands  make  this BASIC
  564.      interpreter a  lot easier to handle data and the BASIC interpreter make
  565.      the spreadsheet a lot powerful  than  many  other  spreadsheet programs
  566.      commercially available.
  567.  
  568.           The arrangement  of this manual consists of three parts. The first
  569.      part consists of 9 example worksheets  as a  tutorial. The  second part
  570.      shows the details of how to use the spreadsheet commands. The last part
  571.      consists of BASIC commands and their usage.
  572.  
  573.           If you have problems in locating cell cursor  with the  mouse, you
  574.      should  read  Appendix  G.  You  should  read  example 1 thoroughly. It
  575.      contains informations for operating the  spreadsheet.  Example  3  is a
  576.      trivial  program  but  it  is  an  important  one  too.  If  you do not
  577.      understand the  cell  reference  method  in  this  program.  You cannot
  578.      understand the  rest examples.  I have tried my best to describe how it
  579.      works. If you still have problem, you should  read PART  III about cell
  580.      reference.
  581.  
  582.           There are  three "big" program listings after the Appendixes. They
  583.      use many commands of SHEET BASIC. You should not miss them too.
  584.  
  585.           Finally,  I  would  like  to  thank  all  the  users  who  provide
  586.      suggestions to make SHEET more useful and reliable. I like to thank Mr.
  587.      Donald A. Edwards and  Dr. Stan  Liebowitz specifically.  Without their
  588.      enthusiasm, I  can hardly imagine some of the features found in version
  589.      2.0. If you have made suggestions but they are not  implemented yet, it
  590.      is not  because they  are being  ignored. Instead, I do not have enough
  591.      time to get everything done on this version.
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.  
  602.  
  603.  
  604.  
  605.  
  606.  
  607.  
  608.  
  609.  
  610.  
  611.  
  612.  
  613.  
  614.  
  615.                                      Page 2
  616.  
  617.  
  618.  
  619.  
  620.  
  621.  
  622.  
  623.  
  624.  
  625.  
  626.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  627.  
  628.                                PART I -- TUTORIAL
  629.  
  630.      Example 1: "AMORT.SHT"
  631.                This example shows you how to  operate with  SHEET. A  lot of
  632.           the basic  ideas of  how to  use the  mouse and your keyboard with
  633.           your worksheet are being introduced. If you understand it, you can
  634.           read PART II without any difficulty.
  635.  
  636.      Example 2: "ROSES.SHT"
  637.                This example  shows you  some advanced feature of spreadsheet
  638.           design. It introduces  the  idea  of  absolute  and  relative cell
  639.           reference.
  640.  
  641.      Example 3: "RANDOM.SHT"
  642.                This example  is a  simple SHEET BASIC program. The main idea
  643.           introduces in this example is a new cell reference method. You can
  644.           use  the  cell  as  a  cell  reference  or as a BASE which you can
  645.           stretch horizontally or vertically.
  646.  
  647.      Example 4: "LOTTERY.SHT"
  648.                This example shows you  how  to  print  your  output  to your
  649.           printer. It  generates 6 different numbers from 1 to 36, and sorts
  650.           those numbers in ascending order, and then prints those numbers to
  651.           your printer.
  652.  
  653.      Example 5: "FTEST.SHT"
  654.                This file shows you the commands for ASCII file accesses.
  655.  
  656.      Example 6: "NUMBER.SHT"
  657.                This file  shows you  how to  use the file access commands to
  658.           retrieve  data  stored  in  ASCII  file  and  then  put  them into
  659.           individual cells.
  660.  
  661.      Example 7: "GRID.SHT"
  662.                This first  graphic program  shows the basic process of using
  663.           the graphic commands.
  664.  
  665.      Example 8: "SINCURVE.SHT"
  666.                This file shows you how to draw a sine curve with the graphic
  667.           commands.
  668.  
  669.      Example 9: "SPLINE.SHT"
  670.                This file  shows you  how to  draw graph using data stored in
  671.           your worksheet.
  672.  
  673.  
  674.  
  675.  
  676.  
  677.  
  678.  
  679.  
  680.  
  681.  
  682.  
  683.                                      Page 3
  684.  
  685.  
  686.  
  687.  
  688.  
  689.  
  690.  
  691.  
  692.  
  693.  
  694.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  695.  
  696.  
  697.      Example 1:
  698.      _________      AMORT.SHT
  699.  
  700.                Amortization means killing something bit by bit. That  is the
  701.           way we handle loans -- we pay little by little.
  702.  
  703.                Suppose  you  are  trying  to borrow $100,000. Your financial
  704.           company provides two options for this loan.
  705.                -    30 years with annual interest rate 9%
  706.                -    20 years with annual interest rate 10.5%
  707.           Intuitively, you may choose  option 1.  Well, let  us analyze this
  708.           problem with SHEET and see whether it is a wise choice.
  709.  
  710.                First, we  have to design our layout. We plan to use column A
  711.           for labels, column B for option  1  and  column  C  for  option 2.
  712.           Following are the steps for creating the template:
  713.  
  714.                Cell entry     Cell cursor    Menu option/Description
  715.           ---------------------------------------------------------
  716.                                              Find  menu  title  "Sheet"  and
  717.                                              select "Defaults".  Choose Text
  718.                                              justification  for  Center  (^)
  719.                                              and select OK.
  720.                               B1             To move your cell cursor to B1,
  721.                                              either move the mouse cursor to
  722.                                              B1 and click the  mouse button,
  723.                                              or use  the arrow  keys to move
  724.                                              the cell cursor. If you use the
  725.                                              mouse to  move your cell cursor
  726.                                              and   if    the   cell   cursor
  727.                                              disappears,   then  you  should
  728.                                              refer to Appendix F.
  729.                Option 1<Return>              Type "Option  1"  and terminate
  730.                                              it with <Return> key.
  731.                               C1             Press the  -> arrow key to move
  732.                                              from cell B1 to C1.
  733.                Option 2<Return>
  734.                               B2
  735.                \-<Return>                    Type "\-" and terminate it with
  736.                                              <Return> key.
  737.                               C2
  738.                \-<Return>
  739.                                              Find  menu  title  "Sheet"  and
  740.                                              choose "Defaults".  Choose Text
  741.                                              justification for Right (")
  742.                               A3
  743.                Amount borrowed<Return>
  744.                               A4
  745.                Annual interest rate<Return>
  746.                               A5
  747.                Total number of terms<Return>
  748.                               A6
  749.                Terms per year<Return>
  750.                               A7
  751.  
  752.                                      Page 4
  753.  
  754.  
  755.  
  756.  
  757.  
  758.  
  759.  
  760.  
  761.  
  762.  
  763.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  764.  
  765.                \-<Return>
  766.                               B7
  767.                \-<Return>
  768.                               C7
  769.                \-<Return>
  770.                               A8
  771.                Payment<Return>
  772.  
  773.  
  774.  
  775.                "\-" means  to fill  up the  cell with "-". You should notice
  776.           that entries on column A occupy some areas of column  B and  C. We
  777.           need to enlarge the width of column A to make rooms for entries on
  778.           column B and C. To widen  column A,  you need  to place  the mouse
  779.           pointer within  the gap  between column  letter A and B. Press the
  780.           mouse button and drag it to the right hand side. (Alternately, you
  781.           can select  the menu  item "Col widths", enter the column name and
  782.           your desired width.) When you press and drag you mouse, you should
  783.           see the  rubber box  expanding.  If the rubber box is large enough
  784.           to cover all the characters of column A, then you can release your
  785.           mouse button. Every text in column A is right justified now.
  786.  
  787.                Well, a  template without  formulas is not a template at all.
  788.           The formula we need for this  calculation is  "LOAN_PAY". It needs
  789.           four arguments  --   amount borrowed,  annual interest rate, total
  790.           number of terms, terms per year.  That is "LOAN_PAY(B3,B4,B5,B6)".
  791.           If you enter the above line into cell B8, SHEET will treat it as a
  792.           TEXT string  instead  of  formula.  That  is  because  the leading
  793.           character of  a cell entry determines its type. A cell starts with
  794.           "+", "-", digit, "(" or "." is a formula. A cell starts with alpha
  795.           character is  a TEXT  string. A  '+' symbol before "LOAN_PAY" will
  796.           tell SHEET to treat it as  a formula.  (NOTE: If  you are  used to
  797.           Lotus  123,  you  may  tempt  to add @ symbol before "LOAN_PAY". @
  798.           symbol in SHEET has different meaning. All the  functions in SHEET
  799.           does  not  require  @  symbol.)  Here  is  the  steps for entering
  800.           "+loan_pay(b3,b4,b5,b7)" on cell B8 and copy the content  of B8 to
  801.           C8.
  802.  
  803.  
  804.                Entry     Mouse     Mouse button   Editing buffer
  805.                          cursor                   display
  806.           --------------------------------------------------------------
  807.                +loan_pay(                         +loan_pay(
  808.                          B3
  809.                                    Mouse click    +loan_pay(B3
  810.                          B4
  811.                <Control>+          Mouse click    +loan_pay(B3,B4
  812.                          B5
  813.                <Control>+          Mouse click    +loan_pay(B3,B4,B5
  814.                          B6
  815.                <Control>+          Mouse click    +loan_pay(B3,B4,B5,B6
  816.                )                                  +loan_pay(B3,B4,B5,B6)
  817.                <Return>
  818.                          B8
  819.  
  820.                                      Page 5
  821.  
  822.  
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  832.  
  833.                <Control>+          Mouse click
  834.                          C8
  835.                <Control>+          Mouse click
  836.                <Control C>
  837.                <Return>
  838.  
  839.  
  840.  
  841.           "<Control>+Mouse click" means press the Control key and left mouse
  842.           button simultaneously.  SHEET  is case-insensitive.  It will treat
  843.           "loan_pay"  as  "LOAN_PAY".  After  those  steps,  you  should see
  844.           0.1e+38 on both B8 and C8. Don't panic. You are not suppose to pay
  845.           that  much  money  even  you    borrow  nothing. This number means
  846.           calculation  error.  During  calculation,  Lotus  uses   11  bytes
  847.           (instead of  8 bytes) to store real number. Special bit pattern is
  848.           set in these 11 bytes to  represent ERR.  Unfortunately, I  do not
  849.           have that  much energy to create my own math package. So, I choose
  850.           the largest number to represent error.
  851.  
  852.                It seems column B and column C are  too close  to each other.
  853.           You should  be able  to change  the column width of column B and C
  854.           without any difficulty now. How wide should they  be? It  is up to
  855.           you.
  856.  
  857.  
  858.                It is time to enter our data to do analysis.
  859.  
  860.                Entry          Cell cursor
  861.           -----------------------------------
  862.                               B3
  863.                100000 <Down arrow>
  864.                               B4
  865.                0.09 <Return>
  866.                               B5
  867.                360 <Return>
  868.                               B6
  869.                12 <Return>
  870.  
  871.  
  872.  
  873.                After you  have typed 100000, you terminate your input by the
  874.           down arrow key. This action changes the editing direction to DOWN.
  875.           Whenever you  terminate your  input with <Return>, the cell cursor
  876.           will automatically move DOWN.  B3 holds  the $100,000  you want to
  877.           borrow. B4  holds the  annual interest rate 9%. B5 holds the total
  878.           number of terms you must pay back to your financial company. It is
  879.           supposed to  be a  monthly payment.  You have to pay 12 times each
  880.           year. Hence, the total number is 30*12 or 360. B6 holds the number
  881.           of terms  per year.  It is  12. NOTE: if your payment is collected
  882.           quarterly, then B6 should be 4 and B5 should be 30*4 or 120.
  883.  
  884.                It is an exercise for you to enter 100000, 0.105,  240 and 12
  885.           into cells  C3, C4,  C5, and C6 are  respectively. The payment for
  886.           option 1 is 804.622617 and it is 998.379887 for option 2. Probably
  887.  
  888.                                      Page 6
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.  
  898.  
  899.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  900.  
  901.           your financial  company will  ask you  to pay  $804.62 and $998.38
  902.           respectively.  To  reflect  this  fact,  you  must  reformat  your
  903.           display. We  need to change B3..C3 and B8..C8 to DOLLAR format and
  904.           B4..C4 to percent (%) format.
  905.  
  906.  
  907.  
  908.                Key       Mouse button   Mouse cursor position
  909.           ----------------------------------------------------
  910.                                         B3
  911.                <Control>+Mouse click
  912.                                         C3
  913.                <Shift>+  Mouse click
  914.                                         B8
  915.                <Control>+Mouse click
  916.                                         C8
  917.                <Shift>+  Mouse click
  918.                <Control R>
  919.                          Select DOLLAR
  920.  
  921.  
  922.  
  923.                The above operations define two blocks. <Control>+mouse click
  924.           on a  cell defines the start of a block and <Shift>+Mouse click on
  925.           a cell defines the end of a block. The first  block is  B3..C3 and
  926.           the  second  block  is  B8..C8. <Control R> activates the reformat
  927.           dialog box. Selection DOLLAR will change cells contained  in those
  928.           blocks to DOLLAR format. I think it is an easy exercise for you to
  929.           change B4..C4 to percent format.
  930.                The payment just tells us we need to pay more for less terms.
  931.           That is  natural. The hidden truth is: we pay more money in option
  932.           1 than option 2.  How can  we find  it? Well,  we pay  804.62 each
  933.           month, and we need to do it 360 times. So, the total amount we pay
  934.           for option 1 is 360*804.62, and 240*998.38 for  option 2.  In cell
  935.           A9, enter  "Total payment".  In B9,  enter 360*b8 and in C9, enter
  936.           240*c8. Comparing the results on B9 and C9, you will  find you pay
  937.           $50,000 less in option 2. So, if you can affort $998.38 per month,
  938.           you should choose option 2.
  939.  
  940.                Now, it  is up  to you  whether you  want to  save your first
  941.           worksheet.  If  you  think  you  don't need it any more. Press the
  942.           window close button and SHEET will give you a last  chance to save
  943.           it. If  you want to save it for future reference, you should press
  944.           <Control S> and enter the file  name in  the file  selector dialog
  945.           box.
  946.  
  947.                You may  even want  to print  it out to show your spouse that
  948.           his/her decision is right or wrong. The following steps will print
  949.           cells A1..C10.
  950.                Key       Mouse button   Mouse cursor
  951.           ----------------------------------------------------
  952.                                         A1
  953.                <Control>+Mouse click
  954.                                         C10
  955.  
  956.                                      Page 7
  957.  
  958.  
  959.  
  960.  
  961.  
  962.  
  963.  
  964.  
  965.  
  966.  
  967.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  968.  
  969.                <Shift>+  Mouse click
  970.                <Control P>
  971.                Fill out the Print dialog box
  972.                <Return>
  973.  
  974.  
  975.  
  976.  
  977.           After this  example, I assume you can operate this program without
  978.      any difficulty. The  tedious  description  of  cell  entries  and mouse
  979.      operations will not appear in the following examples.
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.  
  995.  
  996.  
  997.  
  998.  
  999.  
  1000.  
  1001.  
  1002.  
  1003.  
  1004.  
  1005.  
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011.  
  1012.  
  1013.  
  1014.  
  1015.  
  1016.  
  1017.  
  1018.  
  1019.  
  1020.  
  1021.  
  1022.  
  1023.  
  1024.                                      Page 8
  1025.  
  1026.  
  1027.  
  1028.  
  1029.  
  1030.  
  1031.  
  1032.  
  1033.  
  1034.  
  1035.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  1036.  
  1037.  
  1038.      Example 2:
  1039.      _________      ROSES.SHT
  1040.  
  1041.                This  is  an  inventory  problem. Assume that you are selling
  1042.           roses. Each dozen costs 4  dollars  and  you  are  selling  for 12
  1043.           dollars per dozen. According to your pass experience, you know the
  1044.           probabilities you can sell 10 dozens, 11 dozens, 12 dozens  in one
  1045.           day  are  0.60,  0.23,  0.17.  How many dozens of roses should you
  1046.           order to get the best profit?
  1047.  
  1048.             PROFIT= 12 * actual number of dozens sold - 4 * number of dozens
  1049.                     ordered
  1050.  
  1051.           For example, if you order 11 dozens and you sell only 10 dozens of
  1052.           them, then you earn:
  1053.                PROFIT = 12*10-4*11=76
  1054.  
  1055.           Here  we  need  to  create  the   array  of   profits  for  actual
  1056.           calculation.
  1057.  
  1058.                ordered/  10   11   12
  1059.                sold
  1060.                10        80   76   72
  1061.                11        80   88   84
  1062.                12        80   88   96
  1063.  
  1064.           You may  ask what  is the  meaning of  ordered 10  and sold 11? It
  1065.           means you  sell all  the 10  dozens of  roses and  still there are
  1066.           customers  asking  for  roses.  The  number of roses sold includes
  1067.           actual number  of  dozens  sold  and  number  of  dozens customers
  1068.           asking. If  you have  sold all the roses you have, you cannot give
  1069.           anything to the late customers. So, your profit is 12*10-4*10=80.
  1070.  
  1071.           If you are using calculator to find out those number, then you are
  1072.           not a  good spreadsheet  user. To  calculate the profit table, you
  1073.           must use formula. Now, we  assume  that  the  numbers  ordered are
  1074.           stored from  C1..E1 and  the numbers  sold are stored from B3..B5.
  1075.           The function we need is IFF which means IF Function (I choose this
  1076.           name because  IF is  a reserved key word for BASIC). This function
  1077.           require 3 arguments. The  first one  is a  conditional expression,
  1078.           the second  one is  an expression  returned when  the condition is
  1079.           true, the last one is an expression returned when the condition is
  1080.           false.
  1081.  
  1082.           Here is  the logic:  IF the  number of  dozens we order is greater
  1083.           than the number of dozens we sell, we use the following formula to
  1084.           calculate PROFIT:
  1085.                PROFIT = 12 * dozens ordered - 4 * dozens sold
  1086.           That is  because we can sell no more than we ordered. On the other
  1087.           hand, if the number  of dozens  we order  is not  greater than the
  1088.           number of  dozens we sell, then we can sell as many as we can. The
  1089.           PROFIT will be:
  1090.                PROFIT = 12 * dozens sold - 4 * dozens ordered
  1091.  
  1092.  
  1093.                                      Page 9
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  1105.  
  1106.           So, we enter the following formula in C3:
  1107.                +IFF(C1<B3,12*C1-4*C1,12*B3-4*C1)
  1108.  
  1109.           Now, we can copy this formula to the rest of  the table.  The COPY
  1110.           command does not handle overlap cells correctly. So, we need to do
  1111.           it twice. The first COPY copies  C3 to  C4..C5 and  the second one
  1112.           copies C3 to D3..E5.
  1113.  
  1114.           If you compare the result you get from SHEET with the above table,
  1115.           you may say, column C is correct, but  column D  and E  is totally
  1116.           different. What  is wrong?  Let us examine the content in cell D3.
  1117.           It is:
  1118.                +IFF(D1<C3,12*D1-4*D1,12*C3-4*D1)
  1119.           COPY command will copy  the source  to destination  and modify the
  1120.           destination cell  if its content refers to other cells. The column
  1121.           letter in C3 is increased by one in  D3. Let  us examine  the cell
  1122.           content in cell D4. It is:
  1123.                +IFF(D2<C4,12*D2-4*D2,12*C4-4*D2)
  1124.           In cell  D4, not  only the  column letter changes but also the row
  1125.           number changes. Well,  the  cell  reference  we  choose  is called
  1126.           relative cell reference. We want COPY command just changes what we
  1127.           want but not every cell reference. To do this, we need to  add a $
  1128.           symbol before  the column  letter or the row number. The corrected
  1129.           formula for cell B3 should be:
  1130.                +IFF(C$1<$B3,12*C$1-4*C$1,12*$B3-4*C$1)
  1131.           and you should do the COPY again.
  1132.  
  1133.           Now, we need to find the EXPECTED PROFIT. It is:
  1134.                EP = prob selling 10 * PROFIT selling 10 + prob selling  11 *
  1135.                     PROFIT selling 11 + prob selling 12 * PROFIT selling 12
  1136.           You can  setup the one formula and copy it to find EP for ordering
  1137.           10, 11 and 12.  But  you  can  also  use  the  MATRIX  function to
  1138.           calculate it  easily. Assume  we put the probabilities (0.6, 0.23,
  1139.           0.17) in cells C7..E7. Enter  "Expected  profit"  in  cell  A8 and
  1140.           enter the  formula "+matrix(c8,[c7..e7]*[c3..e5])  in cell A7. You
  1141.           should get 80, 80.8 and 78.84 in cells  C8..E8. Hence  to get more
  1142.           profit, you should order 11 dozens of roses.
  1143.  
  1144.  
  1145.  
  1146.  
  1147.           The above  two examples  show you  some fundamental operations and
  1148.      calculations for using SHEET. The following examples will  show you how
  1149.      to program in SHEET BASIC. Some BASIC experience is required.
  1150.  
  1151.  
  1152.  
  1153.  
  1154.  
  1155.  
  1156.  
  1157.  
  1158.  
  1159.  
  1160.  
  1161.                                      Page 10
  1162.  
  1163.  
  1164.  
  1165.  
  1166.  
  1167.  
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  1173.  
  1174.  
  1175.      Example 3
  1176.      _________      RANDOM.SHT
  1177.  
  1178.                Now,  I  am  going  to  show  you  the  unusual  part of this
  1179.           spreadsheet program  -- the  BASIC interpreter.  This example will
  1180.           generate  100  random  numbers  and calculate the AVERAGE, MEDIAN,
  1181.           MINIMUM,  MAXIMUM,  VARIANCE  and  STANDARD  DEVIATION   of  those
  1182.           numbers.  "C1        :  !R=0" means that cell C1 has the statement
  1183.           "!R=0". If you want to enter the program yourself, you should move
  1184.           your cell  cursor to  C1 and  then enter "!R=0" without the double
  1185.           quotes.    To  run  the  following  BASIC  program,   please  load
  1186.           "RANDOM.SHT" and enter "@run c1" without the double quotes in your
  1187.           editing buffer.
  1188.  
  1189.      C1    : !R=0
  1190.      C2    : ! LOOP 
  1191.      C3    : ! EXIT  IF R=100
  1192.      C4    : !A1[0,R]= RAND
  1193.      C5    : !R=R+1
  1194.      C6    : ! ENDLOOP 
  1195.      C7    : !B3= AVERAGE(A1..A100)
  1196.      C8    : !B4= STD(A1..A100)
  1197.      C9    : !B5= VAR(A1..A100)
  1198.      C10   : !B6= MIN(A1..A100)
  1199.      C11   : !B7= MAX(A1..A100)
  1200.      C12   : !B8= MEDIAN(A1..A100)
  1201.  
  1202.                The above listing  is  printed  by  SHEET.  Here  is  a brief
  1203.           explanation for each line.
  1204.  
  1205.      C1:  R is  a variable  and its  content is initialized to 0. There is a
  1206.           fundamental difference between SHEET  BASIC and  traditional BASIC
  1207.           in  handling  variables  --  YOU MUST initialize all the variables
  1208.           first. If any calculation  involved with  uninitialized variables,
  1209.           you will  be flagged and SHEET BASIC will terminate its operation.
  1210.           Other BASICs treat uninitialized variables as zero. You may have a
  1211.           hard time  to check  typo errors.  So, I FORCE users to initialize
  1212.           variables to eliminate this problem.
  1213.      C2:  LOOP is not available in other  BASICs. This  flow control command
  1214.           is from  Modula-2. I  think sometimes  it is  better than WHILE ..
  1215.           WEND.
  1216.      C3:  EXIT IF is part of LOOP statement. It is an exit for  the LOOP. If
  1217.           the  conditional  expression  for  EXIT  IF is true, then the next
  1218.           command being executed is the one following ENDLOOP.
  1219.      C4:  RAND is the random number generating function. The  left hand side
  1220.           of  the  assignment  statement  is  A1[0,R]  which is a new way to
  1221.           access or store result in cells. We treat cells in  spreadsheet as
  1222.           two  dimensional  array.  You  can  use  the column letter and row
  1223.           number as a cell reference or use the cell reference as a BASE and
  1224.           increases  the  BASE  vertically  or  horizontally by two numbers.
  1225.           These two numbers are separated by comma and  embraced by  "[" and
  1226.           "]". For  example A2[3,4]  is equivalent  to D6. (We assume column
  1227.           letter A is 1 and B  is  2  and  so  on.  A2=[1,2]  and  A2[3,4] =
  1228.           [1,2]+[3,4] =  [4,6]= D6).  In the above listing, if R=12, A1[0,R]
  1229.  
  1230.                                      Page 11
  1231.  
  1232.  
  1233.  
  1234.  
  1235.  
  1236.  
  1237.  
  1238.  
  1239.  
  1240.  
  1241.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  1242.  
  1243.           is referred to cell A13 (A1[0,12] = [1,1]+[0,12] = [1,13] = A13).
  1244.      C5:  Increase the variable R by one.
  1245.      C6:  ENDLOOP statement will force the BASIC  interpreter jumps  back to
  1246.           C3 and test whether R=100. If it is, then the next statement being
  1247.           executed is in C7.
  1248.      C7:  Stores the AVERAGE values of the 100 random number in cell B3
  1249.      C8:  Stores the STANDARD DEVIATION in cell B4
  1250.      C9:  Stores the VARIANCE in cell B5
  1251.      C10: Stores the minimum value to B6
  1252.      C11: Stores the maximum value to B7
  1253.      C12: Stores the MEDIAN in cell B8
  1254.  
  1255.  
  1256.  
  1257.                The logic of the above program will be  more straight forward
  1258.           if we use FOR .. NEXT statement..
  1259.  
  1260.                You  can  generate  100  numbers  by  using  the  spreadsheet
  1261.           commands only.  In cell  A1, enter  "+rand". COPY  a1 to a2..a100.
  1262.           Enter "+average(a1..a100)" in cell b3 and so on.
  1263.  
  1264.  
  1265.                Well, there  are some  difference between these two approach.
  1266.           If you want to get another  set of  random numbers,  you can "@run
  1267.           c1" again. But if you are using the spreadsheet commands, you must
  1268.           COPY it over and  over again  to get  another 100  random numbers.
  1269.           Those AVERAGE,  MIN,MAX ..  functions will hinder your inputs when
  1270.           you are in automatic recalculation mode.
  1271.  
  1272.                If you are programming in traditional  BASICs, you  know that
  1273.           it is  inconvenient to  view the  array which holds the 100 random
  1274.           numbers and you need  to write  a lot  of subroutine  to calculate
  1275.           AVERAGE,MIN,MAX   ....   SHEET   provides   you   the  spreadsheet
  1276.           functionality to help you to handle your date easily and the BASIC
  1277.           interpreter  helps  the  spreadsheet  perform  something that many
  1278.           other spreadsheet users cannot  dream  of.  That  is  some  of the
  1279.           benefit   of   having   a   BASIC  interpreter  in  a  spreadsheet
  1280.           environment.
  1281.  
  1282.  
  1283.  
  1284.  
  1285.  
  1286.  
  1287.  
  1288.  
  1289.  
  1290.  
  1291.  
  1292.  
  1293.  
  1294.  
  1295.  
  1296.  
  1297.  
  1298.                                      Page 12
  1299.  
  1300.  
  1301.  
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  1310.  
  1311.  
  1312.      Example 4:
  1313.      _________      LOTTERY.SHT
  1314.                Everyone wants to be rich. Here is a  program in  SHEET BASIC
  1315.           which may  help you  to get  rich. Well, if you do get any profit,
  1316.           please  share  it  with  me  (grin).  This  is  a  lottery numbers
  1317.           generating program. Here is the listing from SHEET.
  1318.  
  1319.      C1    : ! REDIRECT  TO "prn:"
  1320.      C2    : !R=1
  1321.      C3    : ! LOOP 
  1322.      C4    : !A1[0,R]= INT( RAND*36+1)
  1323.      C5    : !J=1:F= TRUE
  1324.      C6    : ! LOOP 
  1325.      C7    : ! EXIT  IF J=R
  1326.      C8    : ! IF A1[0,J]=A1[0,R] THEN F= FALSE
  1327.      C9    : ! EXIT  IF F= FALSE
  1328.      C10   : !J=J+1
  1329.      C11   : ! ENDLOOP 
  1330.      C12   : ! IF F= TRUE THEN R=R+1
  1331.      C13   : ! EXIT  IF R=7
  1332.      C14   : ! ENDLOOP : SAVE  SCREEN 
  1333.      C15   : ! SORT "A", A2..A7, A1
  1334.      C16   : ! PRINT A2,A3,A4,A5,A6,A7
  1335.      C17   : ! WAIT : RESTORE  SCREEN : EXITGRAPH 
  1336.  
  1337.           Here is a brief explanation.
  1338.      C1:  REDIRECT TO  a file.  This I/O  redirection command causes all the
  1339.           subsequent PRINT commands output to the file specified.  There are
  1340.           some  pre-defined  files.  "prn:"  is  the  printer, "con:" is the
  1341.           monitor and "aux:" is the rs-232 port.
  1342.      C2:  R is a loop counter.
  1343.      C3:  The outer loop for generating 6 different numbers.
  1344.      C4:  INT( RAND*36+1) will generate a random  number from  1 to  36, and
  1345.           this number  is stored  from A2..A7  depends on the value of R. If
  1346.           R=1 then A1[0,R] will be A2  (Remember  A1  is  the  BASE  and its
  1347.           coordinate is [1,1], A1[0,R] = [1,1]+[0,1]=[1,2] = A2).
  1348.      C5:  J is another loop counter which increases from 1 to R. F is a flag
  1349.           to see whether the previous generated number has been picked. F is
  1350.           TRUE  means  no  it  is  not.  By the way, TRUE and FALSE are pre-
  1351.           defined constants. TRUE is equal to 1 and FALSE is 0.
  1352.      C6:  An inner loop to check whether the last number has been picked.
  1353.      C7:  If J=R, it means we check every numbers.
  1354.      C8:  Otherwise, compares each old numbers with  the new  number, if one
  1355.           of them are equal to it, then we set F to FALSE
  1356.      C9:  Well, this  is the second EXIT IF statement within a LOOP. You can
  1357.           have multiple EXIT IF within a LOOP. There is no limit about it.
  1358.      C10: Increase J by 1
  1359.      C11: End of the inner loop
  1360.      C12: If no numbers is equal, then we request for another random number.
  1361.      C13: If 6 numbers have been picked, the loop should be terminated.
  1362.      C14: SAVE SCREEN is a command  to  save  your  current  display.  It is
  1363.           useful if you are printing on screen.
  1364.      C15: SORT is  a worksheet  command which  sort a block in descending or
  1365.           ascending order. The  first  string  "A"  tells  SORT  to  sort in
  1366.  
  1367.                                      Page 13
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.  
  1377.  
  1378.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  1379.  
  1380.           ascending order. A2..A7 is the block being sorted and A1 holds the
  1381.           column that we used for determining  the  place  where  we  try to
  1382.           compare.
  1383.      C16: PRINT cell  A2 to  A7. You  can use comma or semicolon to separate
  1384.           each item for PRINT statement.  Comma  will  make  the  next print
  1385.           position align to 10 characters wide tab.
  1386.      C17: WAIT is  useful when  you output  the data to screen. It stops all
  1387.           the process just wait for you to press <Return> key.  It should be
  1388.           placed before  you restore  your screen.  SORT will not change the
  1389.           appearance of the updated  cells. We  need to  refresh the screen.
  1390.           EXITGRAPH is  a command to refresh the screen. By the way, you can
  1391.           update your screen manually by pressing <Alt-F>.
  1392.  
  1393.  
  1394.                One thing you may notice in this program  is I/O redirection.
  1395.           Here is  a reason why you need to redirect your data to disk file.
  1396.           A user from Canada told me that his  JUKI 6100  Daisywheel printer
  1397.           does not respond to the "end of line" character. So, he prints his
  1398.           worksheet to disk and then use 1st Word  to print  it. If  I don't
  1399.           support I/O redirection in SHEET BASIC, he may need to buy another
  1400.           printer or stop using SHEET..
  1401.  
  1402.                Currently, SHEET BASIC has  command to  redirect output only.
  1403.           Future version should provide input redirection.
  1404.  
  1405.  
  1406.  
  1407.  
  1408.  
  1409.  
  1410.  
  1411.  
  1412.  
  1413.  
  1414.  
  1415.  
  1416.  
  1417.  
  1418.  
  1419.  
  1420.  
  1421.  
  1422.  
  1423.  
  1424.  
  1425.  
  1426.  
  1427.  
  1428.  
  1429.  
  1430.  
  1431.  
  1432.  
  1433.  
  1434.  
  1435.                                      Page 14
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445.  
  1446.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  1447.  
  1448.      Example 5:
  1449.      _________      FTEST.SHT
  1450.  
  1451.                The file  name of  this example  is "FTEST.SHT".  A1..A5 is a
  1452.           program testing the output file  commands.  A7..A13  is  a program
  1453.           testing the  input file  commands. To  run it, enter "@run a1" and
  1454.           "@run a7" separately.
  1455.  
  1456.      A1     :! OPEN "o",#1,"test.txt"
  1457.      A2     :! PRINT #1,"123,456 789": PRINT #1
  1458.      A3     :! PRINT #1,"5623.23,84.38 723.12"
  1459.      A4     :! CLOSE #1
  1460.      A5     :! END 
  1461.  
  1462.      A7     :! GET_FILE "\*.txt", FILENAME$
  1463.      A8     :! OPEN "i",#1, FILENAME$
  1464.      A9     :!R=1: SAVE  SCREEN 
  1465.      A10    :! LOOP 
  1466.      A11    :! INPUT #1, BUF$
  1467.      A12    :! PRINT  BUF$
  1468.      A13    :!R=R+1: ENDLOOP 
  1469.      A14    :! END 
  1470.  
  1471.      Explanation:
  1472.      Explanation
  1473.      A1:  Before we can access a file, we need  to open  it first. Statement
  1474.           A1  open  an  output  file  in  channel  #1  and  the file name is
  1475.           "test.txt". Channel number is in the range of 0~9.
  1476.      A2:  Print the string "123,456 789" and a blank line to the file
  1477.      A3:  Print another string to the file. You can output not only a string
  1478.           but  also  numeric  data  on  the  same line separated by comma or
  1479.           semicolon.
  1480.      A4:  Close channel number 1.
  1481.  
  1482.  
  1483.      A7:  Use the file selector  to  get  the  file  name  from  user. Note:
  1484.           FILENAME$ is a string variable that is changed whenever you change
  1485.           the content of the file selector dialog box.
  1486.      A8:  Open that file as input file on channel #1
  1487.      A9:  R is the counter for line  being  read.  Save  our  current screen
  1488.           first.
  1489.      A10: Enter a loop to read the file line by line.
  1490.      A11: Read a line from the file to BUF$. BUF$ is a string variable which
  1491.           can be modified by INPUT statement only.
  1492.      A12: Print the line being read to the terminal.
  1493.      A13: Increase the  counter of  line number  and repeat  the loop. NOTE,
  1494.           there is  no EXIT  IF statement.  There is no way to detect end of
  1495.           file in current SHEET BASIC. You must let it go  forever until the
  1496.           interpreter finds  end of  file error  and stops your program. You
  1497.           may have some extra "Syntax error" errors. It is normal.
  1498.  
  1499.      NOTE:     After you are  done,  you  can  enter  the  command "@restore
  1500.                screen" to  restore your screen. Also, program A7 can be used
  1501.                to read other text files. You can even read this  document by
  1502.                choosing  this  file  and  you  can stop and resume the print
  1503.                action by <Ctrl-S> and <Ctrl-Q>.
  1504.  
  1505.                                      Page 15
  1506.  
  1507.  
  1508.  
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.  
  1516.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  1517.  
  1518.      Example 6:
  1519.      _________      NUMBER.SHT
  1520.                The file name  for  the  following  program  is "NUMBER.SHT".
  1521.           There  are  two  programs  in  this spreadsheet. The first program
  1522.           generates data to file "test.txt". It is exactly  the same program
  1523.           of Example  5. L7..L16 reads the data from the file "test.txt" and
  1524.           separate each of line into different cells. Subroutine  P1..P11 is
  1525.           used to separate each data into different cells.
  1526.  
  1527.      L1     :! OPEN "o",#1,"test.txt"
  1528.      L2     :! PRINT #1,"123,456 789": PRINT #1
  1529.      L3     :! PRINT #1,"5623.23,84.38 723.12"
  1530.      L4     :! CLOSE #1
  1531.      L5     :! END 
  1532.  
  1533.      L7     :! GET_FILE "*.txt", FILENAME$
  1534.      L8     :! OPEN "i",#1, FILENAME$
  1535.      L9     :!R=0
  1536.      L10    :! LOOP 
  1537.      L11    :! INPUT #1, BUF$
  1538.      L12    :! IF ( ASC( BUF$)<>0) THEN  GOSUB P1
  1539.      L13    :!R=R+1
  1540.      L14    :! ENDLOOP 
  1541.      L15    :! CLOSE #1
  1542.      L16    :! END 
  1543.  
  1544.      P1     :!P=1:C=1
  1545.      P2     :! LOOP 
  1546.      P3     :!Q= POS(" ,", BUF$,P)
  1547.      P4     :! EXIT  IF Q=0
  1548.      P5     :!A1[C,R]= VAL( MID$( BUF$,P,Q-P))
  1549.      P6     :!C=C+1
  1550.      P7     :!P=Q+1
  1551.      P8     :! ENDLOOP 
  1552.      P9     :!A1[C,R]= VAL( MID$( BUF$,P,100))
  1553.      P10    :! RETURN 
  1554.  
  1555.      Explanation:
  1556.      Explanation
  1557.      L1~L5: It is the same code for Example 5 A1~A5.
  1558.      L7:  Uses the file selector to get the file name
  1559.      L8:  Open the file for INPUT.
  1560.      L9:  R is a counter for row number.
  1561.      L10: We enter an infinite loop to read data lines.
  1562.      L11: Read a line from the data file.
  1563.      L12: Test whether  the line  being read  is empty or not. If it is not,
  1564.           then we call subroutine P1 to separate the data into cells.
  1565.      L13: Increase our row number by one.
  1566.      L14: Repeat our loop
  1567.      L15 and L16 is never being  executed.  They  are  there  for decoration
  1568.           only.
  1569.      P1:  P is  the starting  search position and C is the column number. It
  1570.           is zero origin. C=1 means we start from column B.
  1571.      P2:  Enter the loop to separate BUF$ into pieces.
  1572.      P3:  We assume the number is separate by a blank space or comma. POS is
  1573.           a function  that tries  to find  the position  of a blank space or
  1574.  
  1575.                                      Page 16
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  1587.  
  1588.           comma from BUF$ starting from P. If POS cannot find it, Q  will be
  1589.           zero.
  1590.      P4:  Check whether  Q is zero. If it is, then we have checked the whole
  1591.           data line for space and comma and that is the end of our loop.
  1592.      P5:  Store the value of BUF$ from P up to Q-1. It depends  on the value
  1593.           of C and R. If C is 1 and R is 0, then the value will be stored in
  1594.           cell B1. (A1[1,0] is equivalent to B1).
  1595.      P6:  Increase our column number by one.
  1596.      P7:  Change our starting position for P to Q+1
  1597.      P8:  Repeat from P2.
  1598.      P9:  We still have one value after  the  last  space  or  comma.  It is
  1599.           stored from P to the last character of BUF$. If the len of MID$ is
  1600.           larger than the length of BUF$, then it returns a string from P to
  1601.           the last character of BUF$.
  1602.      P10: End our subroutine.
  1603.  
  1604.  
  1605.  
  1606.  
  1607.  
  1608.  
  1609.  
  1610.  
  1611.  
  1612.  
  1613.  
  1614.  
  1615.  
  1616.  
  1617.  
  1618.  
  1619.  
  1620.  
  1621.  
  1622.  
  1623.  
  1624.  
  1625.  
  1626.  
  1627.  
  1628.  
  1629.  
  1630.  
  1631.  
  1632.  
  1633.  
  1634.  
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642.  
  1643.                                      Page 17
  1644.  
  1645.  
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  1655.  
  1656.  
  1657.      Example 7:
  1658.      _________      GRID.SHT
  1659.  
  1660.           This  small  program  shows  the  setup and exit process for using
  1661.      graphics in SHEET BASIC. It just  uses window  1 to  draw the  x and y-
  1662.      axis then marks them. To run it, enter the command "@run d1"
  1663.  
  1664.      D1    : ! WINDOW 1
  1665.      D2    : ! SCALE -7,-2,7,2
  1666.      D3    : ! CLEAR 
  1667.      D4    : ! LINE -7,0,7,0: LINE 0,-10,0,10
  1668.      D5    : ! MARKX 0,-6,6,0.1,0.5
  1669.      D6    : ! MARKY 0,-2,2,0.2,1
  1670.      D7    : ! EXITGRAPH 
  1671.      D8    : ! END 
  1672.  
  1673.      Explanation:
  1674.      Explanation:
  1675.      D1:  The first  command for graphics is WINDOW/VIEWPORT. WINDOW 1 means
  1676.           that we are using window 1 for output.
  1677.      D2:  Setup the scaling factors. The minimum number for X is  -7 and the
  1678.           maximum number is 7 and -2, 2 for Y.
  1679.      D3:  Clear the window being used.
  1680.      D4:  Draws the x-axis and y-axis
  1681.      D5:  Making marks  on x-axis  from -6 to 6 with increment 0.1. A bigger
  1682.           marker on increment of 0.5.
  1683.      D6:  Marks y-axis
  1684.      D7:  Legal way to exit from graphics commands
  1685.  
  1686.      NOTE:
  1687.      ____
  1688.           The first step on graphic command  is WINDOW/VIEWPORT  followed by
  1689.      SCALE. After  that, you can enter any graphic commands. After the graph
  1690.      is  done,  you  should  use  EXITGRAPH  to  reset  the  clipping  area.
  1691.      Otherwise, your screen may seem to be locked up.
  1692.  
  1693.  
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711.  
  1712.  
  1713.  
  1714.                                      Page 18
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.  
  1721.  
  1722.  
  1723.  
  1724.  
  1725.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  1726.  
  1727.      Example 8:
  1728.      _________      SINCURVE.SHT
  1729.  
  1730.           This example  draws a sine curve on the current window. To run it,
  1731.      enter the command "@run a1".
  1732.  
  1733.      A1    : ! WINDOW
  1734.      A2    : ! SCALE -7,-1.2,7,1.2
  1735.      A3    : ! CLEAR 
  1736.      A4    : ! PLOT -2*PI, SIN(-2*PI)
  1737.      A5    : ! FOR X=-2*PI TO 2*PI+0.1 STEP 0.1
  1738.      A6    : ! LINE_TO X, SIN(X)
  1739.      A7    : ! NEXT X
  1740.      A8    : ! LINE -7,0,7,0: LINE 0,-1.2,0,1.2
  1741.      A9    : ! MARKX 0,-7,7,0.5,1
  1742.      A10   : ! MARKY 0,-1.2,1.2,0.1,0
  1743.      A11   : ! LABELX 0,-7,7,1,"f0"
  1744.      A12   : ! LABELY 0,-1.2,1.2,0.2,"f2"
  1745.      A13   : ! WAIT 5: EXITGRAPH
  1746.  
  1747.  
  1748.      Explanation:
  1749.      Explanation:
  1750.      A1:  WINDOW with  no parameter  means we  are using  current window for
  1751.           output.
  1752.      A2:  SCALE for our sine curve.
  1753.      A3:  Clear our window
  1754.      A4:  Plot the first point of our sine curve
  1755.      A5:  A FOR loop to generate a sine wave from -2*PI to 2*PI
  1756.      A6:  Instead of  plotting dots,  we want  to connect  all the dots with
  1757.           lines.
  1758.      A8:  Draws the x- and y-axis.
  1759.      A9:  Marks x-axis
  1760.      A10: Marks y-axis
  1761.      A11: Draws the labels on x-axis. They  are integers  (f0). F  means the
  1762.           number is  displayed in  fixed format. 0 means decimal place is 0.
  1763.           So, it has no decimal place or it is integer.
  1764.      A12: Draws the labels on y-axis. They  are real  number with  2 decimal
  1765.           points.
  1766.      A13: Waits for 5 seconds and then refreshes our window.
  1767.  
  1768.  
  1769.  
  1770.  
  1771.  
  1772.  
  1773.  
  1774.  
  1775.  
  1776.  
  1777.  
  1778.  
  1779.  
  1780.  
  1781.  
  1782.  
  1783.  
  1784.                                      Page 19
  1785.  
  1786.  
  1787.  
  1788.  
  1789.  
  1790.  
  1791.  
  1792.  
  1793.  
  1794.  
  1795.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  1796.  
  1797.      Example 9:
  1798.      _________      SPLINE.SHT
  1799.  
  1800.           This time,  we are  going to  use PLOT  DATA and SPLINE to see how
  1801.      wonderful SPLINE will be. This program has a lot of subroutines. I will
  1802.      explain each. To run it, enter the command "@run c1".
  1803.  
  1804.      F1    : !R=0
  1805.      F2    : ! FOR X=-2*PI TO 2*PI+1 STEP 2
  1806.      F3    : !J1[0,R]=X:K1[0,R]= SIN(X)
  1807.      F4    : !R=R+1
  1808.      F5    : ! NEXT X
  1809.  
  1810.           Subprogram F1 generates 7 data sets for sine curve. The data for x
  1811.      is stored in cells J1..J7 and data for y is stored in cells K1..K7.
  1812.  
  1813.      D1    : ! WINDOW 1
  1814.      D2    : ! CLEAR : SCALE -7,-2,7,2
  1815.      D3    : ! PLOT  DATA J1..J7,K1..K7,0,1
  1816.      D4    : ! GOSUB C13
  1817.      D5    : ! RETURN 
  1818.  
  1819.           Subroutine D1 plots the  data  stored  in  J1..J7,K1..K7  using no
  1820.      marker  and  solid  line.  The  command  PLOT DATA plots data stored in
  1821.      worksheet. J1..J7 and K1..K7  for x,y  respectively. 0  means using dot
  1822.      instead  of  marker  for  each  point  and  1 means using solid line to
  1823.      connect points.
  1824.  
  1825.      D7    : ! WINDOW 1
  1826.      D8    : ! SCALE -7,-2,7,2
  1827.      D9    : ! ATTRIBUTE 1,1
  1828.      D10   : ! SPLINE J1..J7,K1..K7,0.1
  1829.      D11   : ! RETURN 
  1830.  
  1831.           This subroutine draws the spline curve using color  1 (Black). The
  1832.      first argument for ATTRIBUTE sets the color to 1 (Black) and using line
  1833.      width 1. SPLINE uses cubic-spline method  to draw  smooth curve. J1..J7
  1834.      and  K1..K7  define  the  value  for x,y. 0.1 defines the increment for
  1835.      generating data on the spline-curve.
  1836.  
  1837.      F7    : ! WINDOW 1
  1838.      F8    : ! SCALE -7,-2,7,2
  1839.      F9    : !X=-2*PI: PLOT X, SIN(X)
  1840.      F10   : ! ATTRIBUTE 3,1
  1841.      F11   : ! FOR X=-2*PI TO 2*PI STEP 0.1
  1842.      F12   : ! LINE_TO X, SIN(X)
  1843.      F13   : ! NEXT X
  1844.      F14   : ! RETURN 
  1845.  
  1846.           Subroutine F7 draws the actual sine curve using color 3 (Green).
  1847.  
  1848.      C13   : ! LINE 0,-2,0,2: LINE -7,0,7,0: RETURN 
  1849.  
  1850.           Subroutine C13 draws the x- and y-axis
  1851.  
  1852.  
  1853.                                      Page 20
  1854.  
  1855.  
  1856.  
  1857.  
  1858.  
  1859.  
  1860.  
  1861.  
  1862.  
  1863.  
  1864.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  1865.  
  1866.  
  1867.      C1    : ! GOSUB D1
  1868.      C2    : ! GOSUB D7
  1869.      C3    : ! GOSUB F7
  1870.      C4    : ! WAIT 5
  1871.      C5    : ! EXITGRAPH 
  1872.      C6    : ! END 
  1873.  
  1874.           Our main program. First, draws the sine curve with PLOT DATA. Plot
  1875.      the sine  curve with  cubic spline  routine, then draws the actual sine
  1876.      curve. The sine curve using SPLINE is closer to the  actual sine curve.
  1877.      Actually, if  you change  cell F2 with "STEP 1" instead of "STEP 2" and
  1878.      change cells D3 and D10 for ranges J1..J14,K1..K14, then you can hardly
  1879.      tell the difference between the spline-curve and the actual sine-curve.
  1880.      NOTE: the actual sine-curve generates 126 points and  spline-curve uses
  1881.      14 data points! Isn't it wonderful?
  1882.  
  1883.  
  1884.  
  1885.  
  1886.  
  1887.  
  1888.  
  1889.  
  1890.  
  1891.  
  1892.  
  1893.  
  1894.  
  1895.  
  1896.  
  1897.  
  1898.  
  1899.  
  1900.  
  1901.  
  1902.  
  1903.  
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909.  
  1910.  
  1911.  
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918.  
  1919.  
  1920.  
  1921.                                      Page 21
  1922.  
  1923.  
  1924.  
  1925.  
  1926.  
  1927.  
  1928.  
  1929.  
  1930.  
  1931.  
  1932.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  1933.  
  1934.  
  1935.                         PART II -- Spreadsheet operations
  1936.  
  1937.      MENU SELECTIONS:    Briefly  describes  all  the menu selection and its
  1938.                          usage.
  1939.  
  1940.      MOVING AROUND:      This session explains how to move  the working area
  1941.                          to display different part of your worksheet.
  1942.  
  1943.      EDITING:            This  session  discusses  about  cell  entries  for
  1944.                          formula,  constant,  text,   BASIC   statement  and
  1945.                          command. It shows you how to use the line editor.
  1946.  
  1947.      CUSTOMIZED DISPLAY: This chapter  tells you  how to change the width of
  1948.                          individual  column   and  the   display  format  of
  1949.                          individual  cell.   Block  is  introduced  in  this
  1950.                                              _____
  1951.                          chapter too. Block is  important to  many worksheet
  1952.                          commands.
  1953.  
  1954.      COPY AND MOVE:      This  chapter  shows  you  how  to  reorganize your
  1955.                          worksheet. You need to  know how  to select blocks.
  1956.                          It also  discusses about absolute and relative cell
  1957.                          references.
  1958.  
  1959.      ERASE CELLS:        This chapter  explains  to  you  how  to  erase the
  1960.                          unnecessary cells.
  1961.  
  1962.      INSERT AND DELETE:  This session  discusses how  to delete  or insert a
  1963.                          row  or  a  column.  Column  and  row  selection is
  1964.                          different from block.
  1965.  
  1966.      LOAD, SAVE, PRINT:  It explains the menu items under menu title "File".
  1967.  
  1968.  
  1969.  
  1970.  
  1971.  
  1972.  
  1973.  
  1974.  
  1975.  
  1976.  
  1977.  
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984.  
  1985.  
  1986.  
  1987.  
  1988.  
  1989.  
  1990.                                      Page 22
  1991.  
  1992.  
  1993.  
  1994.  
  1995.  
  1996.  
  1997.  
  1998.  
  1999.  
  2000.  
  2001.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  2002.  
  2003.                                  MENU SELECTIONS
  2004.  
  2005.                The menu  titles are the strings that appear on the menu bar.
  2006.                    ____________
  2007.           Menu items refer to the strings that drop  down when  a menu title
  2008.           __________
  2009.           is selected.
  2010.  
  2011.           The menu titles for SHEET looks like this:
  2012.                  Desk  File  Sheet  Row/Col  Cells  Graph  Help
  2013.                  ______________________________________________
  2014.                                                                
  2015.  
  2016.  
  2017.      TITLE     ITEM            Description
  2018.      --------------------------------------------------------------------
  2019.      Desk
  2020.      Desk
  2021.                About SHEET    General information about SHEET.
  2022.  
  2023.      File
  2024.      File                     For a detail description of the following menu
  2025.                               items,  please  refer  to  the  chapter "LOAD,
  2026.                               SAVE, PRINT"
  2027.                New    N       Open  a  new  worksheet  window.  The N on the
  2028.                               right hand side means  that  you  can activate
  2029.                               this  menu  item  by pressing <Control-N>. You
  2030.                               have a choice for changing your  new worksheet
  2031.                               size. The  maximal number of rows can be 50 to
  2032.                               9999.
  2033.                Load   L       Load an old worksheet  file  from  disk drive.
  2034.                               You can  use <Control-L> to activate this menu
  2035.                               item.
  2036.                Load WKS       Load files in the format of  Lotus 123 release
  2037.                               1A or  2. SHEET  is not  a Lotus  clone, so it
  2038.                               will  not  translate  everything.  Whenever it
  2039.                               encounters  problem,  the  translation process
  2040.                               will be terminated.
  2041.                Load PART      Load SHEET files saved  by using  "Save PART".
  2042.                               Its file extension is PRT.
  2043.                Save   S       Save  the   whole  worksheet  file  into  your
  2044.                               diskette.
  2045.                Save WKS       It is supposed to save your worksheet in Lotus
  2046.                               123 file format. It is not working right now.
  2047.                Save PART      Save part of your worksheet into diskette. You
  2048.                               need to  select  blocks  of  cells  before you
  2049.                               activate this menu item.
  2050.                Print  P       Print part  of your worksheet to disk/printer.
  2051.                               You need to select a block before you activate
  2052.                               this menu item.
  2053.                Quit   Q       Quit to desktop.
  2054.  
  2055.  
  2056.      Sheet
  2057.      Sheet
  2058.                Erase          Erase your current worksheet.
  2059.                Defaults       Set  some  default  states  of  SHEET. You can
  2060.                               change the recalculation order  which is saved
  2061.                               with   your   worksheet,   change   the   TEXT
  2062.                               justication, change the  current  window name,
  2063.                               takes 32K  back for  screen redraw  and have a
  2064.  
  2065.                                      Page 23
  2066.  
  2067.  
  2068.  
  2069.  
  2070.  
  2071.  
  2072.  
  2073.  
  2074.  
  2075.  
  2076.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  2077.  
  2078.                               look of the memory remains.
  2079.                Options        In the dialog box  of Options,  you have three
  2080.                               choices.
  2081.                                    Users have  suggested for a Global format
  2082.                               for each  column. "Cell  format using previous
  2083.                               row"  means  that  whenever  you  enter  a new
  2084.                               element for the worksheet, it will try to find
  2085.                               the format  of previous row on the same column
  2086.                               and uses it as default format. So, you  do not
  2087.                               need to reformat again and again.
  2088.                                    If  you  are  moving  the  worksheet with
  2089.                               arrow keys, you will  find that  moving up and
  2090.                               down  is  a  lot  faster  than moving left and
  2091.                               right. "Move  to left/right  Fast" provides an
  2092.                               option that you can move left and right faster
  2093.                               than before. One drawback  for this  option is
  2094.                               that  the   new  column   being  displayed  is
  2095.                               truncated to its own width. Hence you may have
  2096.                               problem  in  displaying  BASIC program or text
  2097.                               string which spilled over other cells.  If you
  2098.                               want  to  redraw  the  screen  to display them
  2099.                               properly, you can use the command "@exitgraph"
  2100.                               or <Alt-F> to redraw the screen.
  2101.                                    Two monochrome users have suggested me to
  2102.                               give an option for  using  the  Small  font to
  2103.                               display more  rows per screen. I have make the
  2104.                               option available but it is not working yet.
  2105.                Dates               SHEET can  display  three  different Date
  2106.                               types.  The  Dates  menu item under menu title
  2107.                               Sheet provides you a new way to show your date
  2108.                               data. The components for a DATE are day, month
  2109.                               and year. Normally, day and year are displayed
  2110.                               as digits. Month can be digit, the first three
  2111.                               characters of the month or the whole alphabets
  2112.                               for  that  month  and some countries put month
  2113.                               before day and some  put day  before month. To
  2114.                               overcome these differences, the date format is
  2115.                               configurable  to   your  favour.   dd  and  yy
  2116.                               represent day and year in digit. mm represents
  2117.                               month in digit. mmm represents month  in three
  2118.                               letters  and  mmmm  represents  month  in full
  2119.                               alphabets. Here are some examples. Assume that
  2120.                               the date is March the first, 1988.
  2121.  
  2122.                               Date format:                   Display:
  2123.                          -------------------------------------------------
  2124.                               mmddyy                        030188
  2125.                               dd-mmm-yy                     01-Mar-88
  2126.                               mmmm dd,19yy                  March 01,1988
  2127.                               dd/mm/yy                      01/03/88
  2128.                               mm/dd/yy                      03/01/88
  2129.  
  2130.                     NOTE:     The  file  SHEET.CFG  holds  the  defnition of
  2131.                               Date1, Date2 and Date3. It is updated whenever
  2132.  
  2133.                                      Page 24
  2134.  
  2135.  
  2136.  
  2137.  
  2138.  
  2139.  
  2140.  
  2141.  
  2142.  
  2143.  
  2144.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  2145.  
  2146.                               you  change  the  Date format. If SHEET.CFG is
  2147.                               not  there  when  SHEET  is  loaded,  then the
  2148.                               default formats will be used.
  2149.  
  2150.      Row/Col
  2151.      Row/Col
  2152.                Insert  I      Insert a  row or  a column. You need to select
  2153.                               that particular row/column first. Refer to the
  2154.                               chapter   "INSERT   AND   DELETE"  for  detail
  2155.                               description.
  2156.                Delete  D      Delete a row or a column.  You need  to select
  2157.                               that particular row/column first.
  2158.                Col widths          You can change the column width in a more
  2159.                               effecient way  than just  using mouse dragging
  2160.                               method. For  example, if  you want to make the
  2161.                               column width from  column  A  to  column  O to
  2162.                               1,9,1,9,1,9,1,9,1,9,1,9,1,9,1,  you can select
  2163.                               the menu item  "Col  widths"  from  menu title
  2164.                               "Row/Col",  enter  "A"  for the leading column
  2165.                               and 1,9,1,9,1,9,1,9,1,9,1  in  the  edit field
  2166.                               "widths".
  2167.  
  2168.      Cells
  2169.      Cells                    NOTE:  YOU  HAVE  TO  SELECT BLOCKS BEFORE YOU
  2170.                               ACTIVATE THE FOLLOWING MENU ITEMS.
  2171.                Reformat  R    Changes the format  of  blocks.  For  a detail
  2172.                               description,   please   refer  to  "CUSTOMIZED
  2173.                               DISPLAY"
  2174.                Erase     E    Erase cells on blocks  specified. Please refer
  2175.                               to "ERASE CELLS".
  2176.                Copy      C    Copy a  block of  cells to other block. Please
  2177.                               refer to "COPY AND MOVE"
  2178.                Move      M    Move a block of cells to other place
  2179.                Adjust    A         Adjust is  used for  changing TEXT string
  2180.                               to   BASIC   statements   or   changing   TEXT
  2181.                               justifications. The first step in using ADJUST
  2182.                               is: Select  the blocks  being ajusted and then
  2183.                               press <Control A> or  select  this  menu item.
  2184.                               You MUST not change TEXT that are not supposed
  2185.                               to be BASIC  statements  to  BASIC statements.
  2186.                               The  program   may  not   recognize  all  your
  2187.                               characters and part of  them may  be truncated
  2188.                               with a character #.
  2189.  
  2190.      Graph
  2191.      Graph                    This selections is not available yet.
  2192.                               This selections is not available yet.
  2193.                Selections
  2194.                Layout
  2195.                Legend
  2196.                X-axis lable
  2197.                Data Variable A
  2198.                Data Variable B
  2199.                Data Variable C
  2200.                Data Variable D
  2201.                Data Variable E
  2202.                Data Variable F
  2203.  
  2204.  
  2205.                                      Page 25
  2206.  
  2207.  
  2208.  
  2209.  
  2210.  
  2211.  
  2212.  
  2213.  
  2214.  
  2215.  
  2216.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  2217.  
  2218.      Help
  2219.      Help
  2220.                Entry          Helps  for  entering  formula,  text  strings,
  2221.                               BASIC statements and commands.
  2222.                Formula        Helps for formula, especially  for calculation
  2223.                               priority
  2224.                Built-in Func  Helps for built-in functions.
  2225.                Statement      Helps for BASIC statements (v1.6)
  2226.                Limits         Helps  for  program  limit  (accuracy, maximum
  2227.                               numbe of variables and so on)
  2228.                Graphic commands Helps for graphic commands for BASIC (v1.7)
  2229.                PTEXT          Helps  for  the  graphic  command  PTEXT (PLOT
  2230.                               TEXT) (v1.7)
  2231.                Commands       Helps on other new BASIC commands (v2.0)
  2232.                Console  commands   Helps  on  screen  control  and  keyboard
  2233.                               commands. (v2.0)
  2234.  
  2235.  
  2236.  
  2237.  
  2238.  
  2239.  
  2240.  
  2241.  
  2242.  
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248.  
  2249.  
  2250.  
  2251.  
  2252.  
  2253.  
  2254.  
  2255.  
  2256.  
  2257.  
  2258.  
  2259.  
  2260.  
  2261.  
  2262.  
  2263.  
  2264.  
  2265.  
  2266.  
  2267.  
  2268.  
  2269.  
  2270.  
  2271.  
  2272.  
  2273.  
  2274.                                      Page 26
  2275.  
  2276.  
  2277.  
  2278.  
  2279.  
  2280.  
  2281.  
  2282.  
  2283.  
  2284.  
  2285.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  2286.  
  2287.  
  2288.                                   MOVING AROUND
  2289.  
  2290.           When you start SHEET,  your screen  is divided  into menu  bar and
  2291.      worksheet  window.  The  worksheet  window  can be divided into 5 major
  2292.      areas. The status line is the first line under the window title.  It is
  2293.                 ___________
  2294.      used for  displaying current  cell's content  and worksheet status. The
  2295.      editing buffer ,which is  the  line  below  status  line,  is  used for
  2296.      ______________
  2297.      entering or  editing the current cell. The column bar is the line below
  2298.                                                 __________
  2299.      the editing buffer. The row bar is located on the left hand side of the
  2300.                              _______
  2301.      worksheet window. Both column and row bars are used for cell reference.
  2302.      The biggest area is the working area for current worksheet.
  2303.                              ____________
  2304.  
  2305.           Each column is referred  by a  unique letter  (from A  to IU). The
  2306.      first column  is A,  column B  after A,  C after  B and  so on. The one
  2307.      following column Z is AA and  after AZ  comes BA,  and so  on. Each row
  2308.      numbers are  sequentially ordered  from 1  to a  variety of  50 to 9999
  2309.      depends on the worksheet size you  choose. A  cell in  the worksheet is
  2310.      referred by  column letter  followed by row number. For example, at the
  2311.      intersection of column B and row number 2 is cell B2.
  2312.  
  2313.           Each spreadsheet  can hold  255 columns  and a  variable number of
  2314.      rows from  50 to 9999. It means you can access at most 2,549,745 cells.
  2315.      Your screen can display a very  small amounts  of them.  Therefore, you
  2316.      have to view your spreadsheet by moving the working area. The following
  2317.      operations let you move your working  area by  keyboard entry  or mouse
  2318.      button.
  2319.  
  2320.           <Up arrow>     If current  cell cursor is not in row number 1, the
  2321.                          cell cursor will be moved one row up.
  2322.           <Down arrow>   If current cell cursor is not  in row  number 1280,
  2323.                          the cell cursor will be moved one row down.
  2324.           <Left arrow>   If current cell cursor is not in column A, the cell
  2325.                          cursor will be moved one column left.
  2326.           <Right arrow>  If current cell cursor is  not  in  column  IU, the
  2327.                          cell cursor will be moved one column right.
  2328.           <Shift-arrows> If  possible,  the  cell  cursor  will  be moved by
  2329.                          "page" to the direction the arrow key specified.
  2330.           <Clr-Home>     This key moves the current cell cursor to A1.
  2331.  
  2332.           <F5>           When you press the function key  F5, you  can enter
  2333.                          the cell reference directly to move the cell cursor
  2334.                          to that cell. If the cell  specified is  not in the
  2335.                          working area, then the working area will be changed
  2336.                          and the new upper left cell is the cell specified.
  2337.  
  2338.           You can use the slider bars to change the working area quite fast.
  2339.      Also, you  can locate a cell with mouse much faster than arrow keys. To
  2340.      locate a cell with mouse:
  2341.                -    use vertical and horizontal slider bars  to move  to the
  2342.                     desired working area.
  2343.                -    put  the  mouse  cursor  over the desired cell and press
  2344.                     left button on your mouse.
  2345.  
  2346.  
  2347.                                      Page 27
  2348.  
  2349.  
  2350.  
  2351.  
  2352.  
  2353.  
  2354.  
  2355.  
  2356.  
  2357.  
  2358.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  2359.  
  2360.                                      EDITING
  2361.  
  2362.      Types of cell entry:
  2363.      ___________________
  2364.                There are 4 different types of cell entries in SHEET: numeric
  2365.           constant, formula,  text and  BASIC statement. BASIC commands will
  2366.           be executed immediately but it will not be stored in any cell. The
  2367.           leading character  of each  entry will  differentiate one from the
  2368.           other.
  2369.  
  2370.  
  2371.                Formula: Input string starts with "+", "-", DIGIT, "." or "("
  2372.                Formula
  2373.  
  2374.                Constant: Input string starts  with "+",  "-", DIGIT,  "." or
  2375.                Constant
  2376.                     "("
  2377.                Statement: Input string starts with "!"
  2378.                Statement
  2379.                Command: Input string starts with "@"
  2380.                Command
  2381.                Text: Input  string starts  with double  quote, single quote,
  2382.                Text
  2383.                     "^", "\" or character other than  "+", "-",  DIGIT, ".",
  2384.                     "(", "!", "@".
  2385.  
  2386.                Constant is  an arithmetic expression which does not refer to
  2387.                Constant
  2388.           other  cell(s)  or  variable(s).  A  constant  cell  will  not  be
  2389.                                                constant
  2390.           recalculated.  You  may  notice  that  most  of  your  inputs  are
  2391.           constants. Making the  distinction  between  formula  and constant
  2392.           constants                                    formula      constant
  2393.           helps speeding up the spreadsheet recalculation time.
  2394.  
  2395.                Statement  and   command  are   for  BASIC  interpreter.  The
  2396.                Statement        command
  2397.           differences between statement and command are that command will be
  2398.                               statement     command          command
  2399.           executed immediately  but will  not be  stored in current cell and
  2400.           statement will not be executed but will be  stored in  the current
  2401.           statement                                          
  2402.           cell.
  2403.  
  2404.                Text  is  a  descriptive  string. The first character of each
  2405.                Text
  2406.           text entry has special effect for display.
  2407.                Single quote('):    The text is left justified.
  2408.                Double quote("):    If the width of  the cell  is larger than
  2409.                                    the length of the text, the text is right
  2410.                                    justified.
  2411.                Circumflex (^):     if the width of  the cell  is larger than
  2412.                                    the  length  of  the  text,  the  text is
  2413.                                    centered within the cell width.
  2414.                Back slash(\):      The text  following  back  slash  will be
  2415.                                    used repetively filling the cell.
  2416.  
  2417.                If  a  text  string  starts  with character other than single
  2418.           quote, double quote, circumflex or back slash, then  the character
  2419.           selected  on  "TEXT  justification"  of menu item "Defaults" under
  2420.           menu title "Sheet" will be used as its leading character.
  2421.  
  2422.                There is a command which you  can change  the first character
  2423.           from one  of ('  " ^ \) to one of (' " ^ \ !). It is the menu item
  2424.           "Adjust" under menu title "Cells".
  2425.  
  2426.  
  2427.  
  2428.  
  2429.  
  2430.                                      Page 28
  2431.  
  2432.  
  2433.  
  2434.  
  2435.  
  2436.  
  2437.  
  2438.  
  2439.  
  2440.  
  2441.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  2442.  
  2443.  
  2444.      Rules for constructing formula:
  2445.      ______________________________
  2446.           When you are entering formula, the  first character  of your entry
  2447.      must be  "+","-", "0".."9",  "." or "(". The following table summarizes
  2448.      all such first characters and their usage.
  2449.  
  2450.           Char Usage                                        Example
  2451.      -----------------------------------------------------------------
  2452.           +    Used when the formula begins with  a cell    +A1/A2
  2453.                reference or calling built-in function       +SIN(A1)
  2454.  
  2455.           -    Used   when   the   formula  begins  with    -A1*20
  2456.                negative constant value or negative value    -12*0.2
  2457.                of  cell  reference  or negative value of    -COS(A1)
  2458.                function call
  2459.  
  2460.           0-9  Used  when  the  formula  begins  with  a    12.3*20
  2461.                constant number.
  2462.  
  2463.           .    Used  when  the  formula  begins  with  a    .05*120
  2464.                constant number.
  2465.  
  2466.           (    Used  when  the  beginning  part  of  the    (A1-A2)/A3
  2467.                formula's  natural  order  of calculation
  2468.                must be altered through the use of a pair
  2469.                of parentheses.
  2470.  
  2471.  
  2472.           NOTE: 1.
  2473.           ____      Versions before  2.0 of  SHEET did  not know that .05 is
  2474.                     0.05.
  2475.                 2.  If part of the expression returns a string, then it will
  2476.                     treat as 0. It means you cannot do string calculation in
  2477.                     any  cell.  But  the  BASIC  interpreter  can  do string
  2478.                     operations.
  2479.  
  2480.                  eg.     34+chr$(12)         ==>34
  2481.                          "test1"+"test2"     ==>0
  2482.                          4+len("some")       ==>8
  2483.  
  2484.  
  2485.  
  2486.  
  2487.  
  2488.  
  2489.  
  2490.  
  2491.  
  2492.  
  2493.  
  2494.  
  2495.  
  2496.  
  2497.  
  2498.  
  2499.  
  2500.                                      Page 29
  2501.  
  2502.  
  2503.  
  2504.  
  2505.  
  2506.  
  2507.  
  2508.  
  2509.  
  2510.  
  2511.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  2512.  
  2513.      Cell input:
  2514.      __________
  2515.                Whenever  you  type  some  keys, the corresponding characters
  2516.           will be inserted into  the  editing  buffer.  You  may  notice the
  2517.           status  is  changed  from  "Ready"  to "Input". Your entry must be
  2518.           terminated by the following  method to  change the  status back to
  2519.           "Ready". While  you are  in "Input"  mode, the menu selections and
  2520.           window resize function are not allowed, though you can change your
  2521.           working  area  by  moving  the horizontal or vertical slider bars.
  2522.           Whenever you terminate  your  input,  you  will  get  back  to the
  2523.           working area before you do editing.
  2524.  
  2525.           Move the editing cursor:
  2526.           Move the editing cursor
  2527.           <Shift-Left arrow>  Moves the  editing cursor  to left  by 1/2 the
  2528.                               length of the editing buffer.
  2529.           <Shift-Right arrow> Moves the editing cursor  to right  by 1/2 the
  2530.                               length of the editing buffer.
  2531.                MOUSE cursor   Moves  the  mouse  cursor to the character you
  2532.                               want it  be  and  press  left  button  on your
  2533.                               mouse,  then  the  editing cursor will move to
  2534.                               that character.
  2535.           Modify your input:
  2536.           Modify your input
  2537.                <Insert>       Toggles the INSERT mode  to TYPEOVER  mode and
  2538.                               vice versa.
  2539.                <Backspace>    Erases the  character on the left hand side of
  2540.                               the editing cursor.
  2541.                <Delete>       Erases the character under the editing cursor.
  2542.           Terminate your input:
  2543.           Terminate your input:
  2544.                <Undo>         Terminates input and the  cell content  is not
  2545.                               modified.
  2546.                <Return>       Terminates input  and the cell cursor moves to
  2547.                               the direction specified  by  editing direction
  2548.                               (see below).
  2549.                <UP arrow>     Terminates input and the cell cursor moves one
  2550.                               row up if possible.
  2551.                <Down arrow>   Terminates input and the cell cursor moves one
  2552.                               row down if possible.
  2553.                <Left arrow>   Terminates input and the cell cursor moves one
  2554.                               column left if possible.
  2555.                <Right arrow>  terminates input and the cell cursor moves one
  2556.                               column right if possible.
  2557.           Miscellaneous operations:
  2558.           Miscellaneous operations:
  2559.                MOUSE          if the mouse cursor is inside the working area
  2560.                               and if  you  press  the  left  button  on your
  2561.                               mouse, the  cell coordinate  that the mouse is
  2562.                               over will be inserted into the editing buffer.
  2563.           <Control> MOUSE     It works as above  except a  comma is inserted
  2564.                               before the cell coordinate.
  2565.           <Shift> MOUSE       Instead  of  comma,  a  through  notation (..)
  2566.                               added before the cell coordinate.
  2567.                Sliders        You can change the working area  by moving the
  2568.                               vertical   or   horizontal  slider  bars.  Any
  2569.                               terminating key  will resume  the display back
  2570.                               to the working area before editing.
  2571.  
  2572.  
  2573.                                      Page 30
  2574.  
  2575.  
  2576.  
  2577.  
  2578.  
  2579.  
  2580.  
  2581.  
  2582.  
  2583.  
  2584.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  2585.  
  2586.      Modify a cell:
  2587.      _____________
  2588.                To modify  a cell,  you have  to move  the cell cursor to the
  2589.           desired cell. Press the function key <F2> and use the above method
  2590.           to modify  the cell  content but you must terminate your change by
  2591.                                                ______________
  2592.           <Return>. If you change your mind, you can always <Undo>  what you
  2593.           have done.
  2594.  
  2595.      Editing direction:
  2596.      _________________
  2597.                When you  terminate your  input by any arrow key, the editing
  2598.           direction  will  be  changed  to  the  direction  the   arrow  key
  2599.           specified. When  you press  <Return> to  terminate your input, the
  2600.           cell cursor will move  to the  editing direction.  If you  want to
  2601.           change  the  editing  direction  to  neutral,  you  have  to press
  2602.           <Return> before your editing session.
  2603.  
  2604.                e.g.
  2605.  
  2606.  
  2607.                Cell      Entry                    Cell cursor position
  2608.           -------------------------------------------------------------
  2609.                 A1       1 <Down arrow>                 A2
  2610.  
  2611.                 A2       2 <Return>                     A3
  2612.  
  2613.  
  2614.                The first entry change the editing  direction to  <Down>. The
  2615.           second  entry   which  terminates  with  <Return>  is  similar  to
  2616.           terminating with <Down arrow>.
  2617.  
  2618.  
  2619.  
  2620.  
  2621.  
  2622.  
  2623.  
  2624.  
  2625.  
  2626.  
  2627.  
  2628.  
  2629.  
  2630.  
  2631.  
  2632.  
  2633.  
  2634.  
  2635.  
  2636.  
  2637.  
  2638.  
  2639.  
  2640.  
  2641.  
  2642.  
  2643.  
  2644.                                      Page 31
  2645.  
  2646.  
  2647.  
  2648.  
  2649.  
  2650.  
  2651.  
  2652.  
  2653.  
  2654.  
  2655.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  2656.  
  2657.                                CUSTOMIZED DISPLAY
  2658.  
  2659.           SHEET can calculate number  accurate up  to 17  decimal places. In
  2660.      most case, you need to display 2 decimal points only. For example, your
  2661.      monthly loan payment may be 876.54321.  You  will  not  care  about the
  2662.      extra digits. You just want it to display as 876.54 or $876.54. That is
  2663.      the situation in which you need to change its default display format.
  2664.  
  2665.           There are two ways to change  the appearance  of your worksheets--
  2666.      changing  the  width  of  individual  column and changing the format of
  2667.      individual cells.
  2668.  
  2669.  
  2670.      Change column width:
  2671.      ___________________
  2672.           The column width of  a cell  may affect  the display.  For numeric
  2673.      result, if  the format  you specify  cannot fit  into the  width of the
  2674.      cell, then the cell will be filled up with "*".  For text,  you may not
  2675.      be able  to do  right justification  or center the text. To display the
  2676.      result correctly, you may need to change the width of the column.
  2677.  
  2678.           There are two ways to change the width  of individual  column. The
  2679.      first way  uses the  mouse and  the second  way uses the menu item "Col
  2680.      widths" under menu title "Row/Col".
  2681.  
  2682.           MOUSE:
  2683.                -    Move the desired column within the working area
  2684.                -    Move the mouse cursor on the white gap  after the column
  2685.                     letter (e.g.  if you  want to change the width of column
  2686.                     A, move the mouse cursor on  the white  gap after column
  2687.                     letter A)
  2688.                -    Press the left mouse button (do not release it)
  2689.                -    To expand  the column width, drag the mouse to right and
  2690.                     release the button
  2691.                -    To shrink the column width, drag  the mouse  to left and
  2692.                     release the column
  2693.           Col widths:
  2694.                -    Select the  menu item  "Col widths" under the menu title
  2695.                     "Row/Col".
  2696.                -    Enter the correct column letter
  2697.                -    Enter your desired column width.
  2698.                -    You can enter numbers separate by comma. Doing this will
  2699.                     change  the  column  widths  beginning  from  the column
  2700.                     letter specified.
  2701.       
  2702.           Note:
  2703.           Note      if your column width is only 1 character  wide, then the
  2704.                     column letter will be pushed to the next column.
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710.  
  2711.  
  2712.  
  2713.  
  2714.                                      Page 32
  2715.  
  2716.  
  2717.  
  2718.  
  2719.  
  2720.  
  2721.  
  2722.  
  2723.  
  2724.  
  2725.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  2726.  
  2727.  
  2728.      Default display format:
  2729.      ______________________
  2730.           Text:
  2731.           Text      Depends on the first character for justification.
  2732.           Constant and Formula:
  2733.           Constant and Formula
  2734.                     The number  of digits after the decimal point is six. It
  2735.                     is right justified and if  possible,  a  blank  space is
  2736.                     added at the rightmost place.
  2737.           Column width:  9 characters per column.
  2738.           Column width
  2739.  
  2740.  
  2741.      Display format:
  2742.      _______________
  2743.                There are  9 different predefined display formats for formula
  2744.                                                                      formula
  2745.           and constant types. The first one is the  default format mentioned
  2746.               constant
  2747.           above.  The  others  are  %,  Fixed, Scientific, Dollar, ,(comma),
  2748.                                     %   Fixed  Scientific  Dollar  ,
  2749.           Date1, Date2, Date3.
  2750.           Date1  Date2  Date3
  2751.  
  2752.  
  2753.                Type      Usage                         Example
  2754.           --------------------------------------------------------
  2755.             Default    Display up to 6 decimal points    3.1234
  2756.             %          Use    for    interest    rate,   0.05    will    be
  2757.                        discount, tax and so on.          displayed as 5%
  2758.             Fixed      Use   for   data   which   have   1.00
  2759.                        different  decimal  places. (eg   1.50
  2760.                        1,1.5. Most likely, you want it   2.00
  2761.                        to be 1.00, 1.50)
  2762.             Scienti-   Use for display data which is a   3.24e12
  2763.             fic        big or small number.
  2764.  
  2765.             Dollar     Use for data which  are related   $1,245.12
  2766.                        to money.
  2767.             ,          Comma  format   is  similar  to   1,245.12
  2768.                        Dollar format excep there is no
  2769.                        dollar sign in front of it.
  2770.             Date1      Use for displaying date related   9-Jul-88
  2771.                        value. Its format is dd-MMM-yy.
  2772.             Date2      Its format is dd-mmm.             18-Jul
  2773.             Date3      Its format is mmm-yy.             Jul-88
  2774.             TEXT       Display formula  instead of its
  2775.                        value.
  2776.  
  2777.             HIDE       The  information  on  this cell
  2778.                        will not appear on  the working
  2779.                        area
  2780.  
  2781.  
  2782.  
  2783.  
  2784.  
  2785.  
  2786.  
  2787.  
  2788.  
  2789.  
  2790.  
  2791.                                      Page 33
  2792.  
  2793.  
  2794.  
  2795.  
  2796.  
  2797.  
  2798.  
  2799.  
  2800.  
  2801.  
  2802.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  2803.  
  2804.  
  2805.      Block:
  2806.      _____
  2807.           Before we  reformat some  cells, we need to tell SHEET which cells
  2808.      we intend to do that. In SHEET, those cells are called blocks. In Lotus
  2809.      123, we can define only one block at one time, but SHEET can accomodate
  2810.      up to 18 blocks at one time.
  2811.  
  2812.           A block is part of the spreadsheet. It is a  rectangle which holds
  2813.      at least  one cell.  To define a block, you need to select the starting
  2814.                                                                     ________
  2815.      cell and stopping cell  of  the  block.  The  process  of  defining the
  2816.      ____     _____________
  2817.      starting  cell  requires  mouse  button and <Control> key, and stopping
  2818.      ______________                                                 ________
  2819.      cell requires mouse button and <Shift> key.
  2820.      ____
  2821.  
  2822.                Here is an example to define cell A5 as a block:
  2823.  
  2824.                -    Move the mouse cursor within cell A5
  2825.                -    Press  <Control>  key   and   the   left   mouse  button
  2826.                     simultaneously
  2827.  
  2828.                You may  notice that  the selected block has been highlighted
  2829.           by reversing its color.
  2830.  
  2831.                Here is another example  to show  you how  to define  a block
  2832.           containing cells from B5 to C14 (B5..C14):
  2833.                -    Move the mouse cursor within cell B5
  2834.                -    Press   <Control>   key   and   the  left  mouse  button
  2835.                     simultaneously
  2836.                -    Move the mouse cursor within cell C14
  2837.                -Press <Shift> key and the left mouse button simultaneously.
  2838.  
  2839.                In summary, to define the starting cell, you have to move the
  2840.                                          _____________
  2841.           mouse  cursor  over  the  first  cell and press <Control> and left
  2842.           mouse button simultaneously. To define the stopping cell, you have
  2843.                                                      _____________
  2844.           to move  the mouse cursor over the last cell and press <Shift> and
  2845.           left mouse button simultaneously. If no stopping cell  is provided
  2846.                                                   _____________
  2847.           then the stopping cell is the starting cell.
  2848.  
  2849.                Using  above  example,  if  you  want to define block B5..B14
  2850.           instead of B5..C14
  2851.                -    Move the mouse cursor within cell B14
  2852.                -    Press <Shift>  key and  the left  mouse button simultan-
  2853.                     eously.
  2854.  
  2855.                If block  B5..C14 is  the first  block you  defined, there is
  2856.           another way to select this block:
  2857.                -    move the mouse cursor within the cell B5
  2858.                -    press the left mouse button  and  drag  until  you reach
  2859.                     cell C14
  2860.                -    release mouse button.
  2861.  
  2862.      De-select blocks:
  2863.      ________________
  2864.                Selecting any cell by a mouse button click will de-select all
  2865.           the blocks being selected.
  2866.  
  2867.  
  2868.                                      Page 34
  2869.  
  2870.  
  2871.  
  2872.  
  2873.  
  2874.  
  2875.  
  2876.  
  2877.  
  2878.  
  2879.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  2880.  
  2881.      Change display format:
  2882.      _____________________
  2883.           To reformat some cells:
  2884.                -    select blocks using above method
  2885.                -    Press <Control R>
  2886.                     or  find  menu  title  "Sheet"  and   choose  menu  item
  2887.                     "Reformat" under it.
  2888.                -    A dialog  box will  show up.  Choose the format you want
  2889.                     from it.
  2890.  
  2891.                You can also use the  command  "@REFORAMT"  to  reformat some
  2892.           cells. The command should be:
  2893.                -    @reformat FORMAT_STRING, block1, block2, ....
  2894.                -    FORMAT_STRING consists  of two  part. The  first part is
  2895.                     the format  being  used,  and  the  second  part  is the
  2896.                     decimal places.  The format  of a  cell can be "$", ",",
  2897.                     "%", "F", "S" "D1",  "D2" and  "D3". They  represent the
  2898.                     format    of    "DOLLAR",   ",",   "PERCENT",   "FIXED",
  2899.                     "SCIENTIFIC", "Date1", "Date2" and "Date3" respectively.
  2900.  
  2901.                For example, if you want to  reformat cell  B2..C2 and B5..C5
  2902.           to DOLLAR with decimal place of 2, you can issue the command
  2903.                           @reformat "$2",b2..c2,b5..c5
  2904.           instead of selecting blocks and press <Control R>.
  2905.  
  2906.  
  2907.           NOTE:
  2908.           NOTE      YOU CAN  ONLY REFORMAT  THOSE CELLS WHICH EXIST. That is
  2909.                     because of Sparse Matrix. After a cell has been created,
  2910.                     the cell  possesses attributes. If you format some empty
  2911.                     cells and insert something into those  cells after that,
  2912.                     those cells appear as default. It is not a bug.
  2913.  
  2914.                     You  can  set  the  option  in menu item "Options" under
  2915.                     "Sheet"  to  use  the  format  of  previous  row.  Then,
  2916.                     whenever you  enter a  new element for the worksheet, it
  2917.                     will try to find the format of previous row on  the same
  2918.                     column and  uses it  as default  format. So,  you do not
  2919.                     need to reformat again and again.
  2920.  
  2921.  
  2922.  
  2923.  
  2924.  
  2925.  
  2926.  
  2927.  
  2928.  
  2929.  
  2930.  
  2931.  
  2932.  
  2933.  
  2934.  
  2935.  
  2936.  
  2937.  
  2938.                                      Page 35
  2939.  
  2940.  
  2941.  
  2942.  
  2943.  
  2944.  
  2945.  
  2946.  
  2947.  
  2948.  
  2949.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  2950.  
  2951.                                   COPY AND MOVE
  2952.  
  2953.                COPY and MOVE commands require two blocks. The first block is
  2954.           the source,  and the second one is destination. You have to select
  2955.           those blocks before you  activate COPY  command by  <Control C> or
  2956.           find the  menu title "Cells" and choose menu item "Copy" under it.
  2957.           To activate MOVE command, you press <Control M> or find menu title
  2958.           "Range" and choose menu item "Move" under it.
  2959.  
  2960.                You can  use the  command "@COPY source_block, dest_block" or
  2961.           "@MOVE source_block, dest_block" to do the same thing.
  2962.  
  2963.                Here is an example  showing you  how to  copy the  content on
  2964.           cell A1  to A2..A5.  Assume that  the content of A1 is "1+A2". The
  2965.           display of cell A1 should be 1.
  2966.  
  2967.  
  2968.                Key       Mouse button   Effect              Mouse cursor
  2969.                                                               position
  2970.           -----------------------------------------------------------
  2971.                                                             A1
  2972.                Control + Mouse click    Cell A1 inverted
  2973.                                                             A2
  2974.                Control + Mouse click    Cell A2 inverted
  2975.                                                             A5
  2976.                Shift +   Mouse click    Cell A2 through
  2977.                                         A5 inverted.
  2978.                Control C                An alert box
  2979.                                         display on screen
  2980.                Return or Mouse click
  2981.                          on OK.
  2982.  
  2983.                The operations prior to  <Control C>  define two  blocks. The
  2984.           first block consists of cell A1 only. The second block consists of
  2985.           cells A2 through A5. <Control C> tells SHEET  to copy  the content
  2986.           of  the  first  block  to  the  second  block. If cell A6 does not
  2987.           contain anything and you  set the  recalculation mode  to Natural,
  2988.           your display should be:
  2989.                          A              Cell content
  2990.                1              5         1+A2
  2991.                2              4         1+A3
  2992.                3              3         1+A4
  2993.                4              2         1+A5
  2994.                5              1         1+A6
  2995.  
  2996.                Natural recalculation  means formulas are calculated in their
  2997.           dependent order. Cell A1 depends on the result  of A2  (1+A2). So,
  2998.           the calculation  of A1  is postponed  until A2 gets its result. A2
  2999.           depends on  A3 and  A3 depends  on A4  and so  on. Thererfore, the
  3000.           first  formula  being  computed  is  A5. If a formula refers to an
  3001.           empty cell, a zero  will be  returned. Hence,  A5=1+A6=1+0=1, cell
  3002.           A4=1+A5=1+1=2 and A3=1+A4=1+2=3 ...
  3003.  
  3004.  
  3005.  
  3006.                                      Page 36
  3007.  
  3008.  
  3009.  
  3010.  
  3011.  
  3012.  
  3013.  
  3014.  
  3015.  
  3016.  
  3017.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  3018.  
  3019.                One question  you may  ask: Why  the cell  reference of A2 in
  3020.           cell A1 has been changed to A3, A4, A5 and A6 in  cell A2,  A3, A4
  3021.           and A5 respectively? The answer is relative cell reference.
  3022.  
  3023.      Relative and Absolue cell reference:
  3024.      ___________________________________
  3025.                Cell reference  can be  absolute or  relative. By  adding a $
  3026.                
  3027.           symbol before the column letter or/and row number,  we designate a
  3028.           part of  a cell address as absolute or both parts as absolute. For
  3029.           example:
  3030.                $A2  denotes column  (A)  is  absolute  and  the  row  (2) is
  3031.                     relative.
  3032.                $A$2 denotes column (A) and row (2) are both absolute.
  3033.                A$2  denotes  column  (A)  is  relative  and  the  row (2) is
  3034.                     absolute
  3035.                A2   denotes column (A) and row (2) are both relative.
  3036.  
  3037.                During  COPY,  a  formula  in  source  block  which  contains
  3038.           relative  cell  references  will  be  modified.  If the formula is
  3039.           copied down, then the  relative row  number will  be increased. If
  3040.           the formula is copied to right hand side, then the relative column
  3041.           letter will be increased. If you intend to copy "1+A2"  to A2..A5,
  3042.           then you must use formula "1+A$2" instead of "1+A2".
  3043.  
  3044.      NOTE:
  3045.      NOTE:
  3046.                A  block  can  be  a  single  cell  (A2),  part  of  a column
  3047.           (A2..A5),part of  a  row  (B20..E20)  or  a  range  (A4..C10). The
  3048.           following  describes  how  the  program  handle different types of
  3049.           block COPY. Source is  the  first  block  and  destination  is the
  3050.           second block. Result is the range size chosen by COPY.
  3051.  
  3052.                Source              Destination         Result size
  3053.           --------------------------------------------------------- 
  3054.                 Single cell        any kind of block    the largest range
  3055.                 column reference   any kind of block    the largest range
  3056.                 row reference      any kind of block    the largest range
  3057.                 range reference    any kind of block    the source range
  3058.  
  3059.  
  3060.           You can use "@COPY" to copy from source to destination too.
  3061.           You can use "@COPY" to copy from source to destination too.
  3062.  
  3063.           Examples:
  3064.                - If you want to COPY C1 to C2..C20
  3065.                     * Control and mouse click on cell C1
  3066.                     * Control and mouse click on cell C2
  3067.                     * Shift and mouse click on cell C20
  3068.                     * <Control C>
  3069.                 OR: "@COPY c1,c2..c20"
  3070.                - If you want to COPY C1..C12 to D1..D12
  3071.                     * Control and mouse click on cell C1
  3072.                     * Shift and mouse click on cell C12
  3073.                     * Control and mouse click on cell D1
  3074.                     * <Control C>
  3075.                 OR: "@COPY c1..c12,d1"
  3076.  
  3077.  
  3078.                                      Page 37
  3079.  
  3080.  
  3081.  
  3082.  
  3083.  
  3084.  
  3085.  
  3086.  
  3087.  
  3088.  
  3089.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  3090.  
  3091.                                    ERASE CELLS
  3092.  
  3093.                After some practice, you may find some data in your worksheet
  3094.           are no longer needed. Hence,  you  need  the  capability  to erase
  3095.           them. Before  you activate  the ERASE command, you must select the
  3096.           desired cells as blocks. Yes, you can erase  more than  one block,
  3097.           but  the  total  number  of  blocks  cannot  exceed 18. Here is an
  3098.           example showing you how to erase  cells  C1..D11,  E5,  F8  at one
  3099.           time.
  3100.  
  3101.                Key       Mouse button   Effect              Mouse cursor
  3102.                                                               Position
  3103.           ----------------------------------------------------------------
  3104.                                                             C1
  3105.                Control + Mouse button   C1 is inverted
  3106.                                                             D11
  3107.                Shift +   Mouse button   C1 through D11
  3108.                                         are inverted
  3109.                                                             E5
  3110.                Control + Mouse button   E5 is inverted
  3111.                                                             F8
  3112.                Control + Mouse button   F8 is inverted
  3113.                Control E                An alert box for
  3114.                                         ERASE command on
  3115.                                         screen
  3116.                Return or Mouse button   The screen will be
  3117.                          on OK          redrawn to show the
  3118.                                         effect of erase.
  3119.  
  3120.  
  3121.      Note:
  3122.      ____      Instead of  using mouse  operations, you  can use the command
  3123.                "@ERASE" to erase part of  your  worksheet.  To  do  the same
  3124.                thing as above, you can issue the command:
  3125.  
  3126.                               @erase c1..d11,e5,f8
  3127.  
  3128.  
  3129.  
  3130.  
  3131.  
  3132.  
  3133.  
  3134.  
  3135.  
  3136.  
  3137.  
  3138.  
  3139.  
  3140.  
  3141.  
  3142.  
  3143.  
  3144.  
  3145.  
  3146.  
  3147.                                      Page 38
  3148.  
  3149.  
  3150.  
  3151.  
  3152.  
  3153.  
  3154.  
  3155.  
  3156.  
  3157.  
  3158.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  3159.  
  3160.                                 INSERT AND DELETE
  3161.  
  3162.                INSERT and DELETE commands work with row and column only. The
  3163.           first thing before we activate INSERT  or DELETE  command, we must
  3164.           select a row/column.
  3165.  
  3166.      Row/Column selection:
  3167.      ____________________
  3168.           Here is an example to show you how to select column D:
  3169.                Mouse cursor position         Mouse button
  3170.           ------------------------------------------------------
  3171.                COLUMN BAR
  3172.                column letter D
  3173.                                              Click the mouse button
  3174.                After you select column D, the whole column will be inverted.
  3175.  
  3176.           This is an example showing you how to select row 3
  3177.  
  3178.  
  3179.                Mouse cursor position         Mouse button
  3180.           ------------------------------------------------------
  3181.                ROW BAR
  3182.                row number 3
  3183.                                              Click the mouse button
  3184.  
  3185.  
  3186.                After you select row 3, the whole row will be inverted.
  3187.  
  3188.  
  3189.                To delete  or insert  a row/column, you must first select the
  3190.           row/column by clicking on  the  column  or  row  bar  with desired
  3191.           column letter or row number. After that, you can press <Control I>
  3192.           or <Control D> for inserting or deleting. You can choose  the menu
  3193.           title "Row/Col"  and choose  menu item  "Insert" or "Delete" to do
  3194.           the same thing.
  3195.  
  3196.      Note:
  3197.      ____      INSERT and DELETE commands work with row and column only.
  3198.           -    If you intend to add some blank rows or column but you do not
  3199.                want to  add the  whole rows/columns,  then you must use MOVE
  3200.                command instead.
  3201.           -    If you intend to delete  some  cells,  use  ERASE  instead of
  3202.                DELETE.
  3203.  
  3204.  
  3205.  
  3206.  
  3207.  
  3208.  
  3209.  
  3210.  
  3211.  
  3212.  
  3213.  
  3214.  
  3215.  
  3216.  
  3217.                                      Page 39
  3218.  
  3219.  
  3220.  
  3221.  
  3222.  
  3223.  
  3224.  
  3225.  
  3226.  
  3227.  
  3228.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  3229.  
  3230.                                  LOAD, SAVE AND PRINT
  3231.  
  3232.                If you  take a  look of the menu title "File", you may notice
  3233.           that there are three types of  load and  save commands.  Menu item
  3234.           "Load"  will  load  the  ordinary  SHEET  files  (they have a file
  3235.           extension SHT). "Load WKS"  will  load  Lotus  123  release  1A or
  3236.           release  2  files.  "Load  PART"  is similar to Lotus file combine
  3237.           command. It is  used  for  merging  other  worksheet  with current
  3238.           worksheet.  The  file  you  "Load"  with part should be saved with
  3239.           "Save PART" command and its file extension should be PRT.
  3240.  
  3241.                Menu item "Save" will save the current file using SHT format.
  3242.           "Save  WKS"  will  save  file  in Lotus WKS format. "Save PART" is
  3243.           similar to Lotus file extract command. It is used for  saving some
  3244.           part  of  the  current  worksheet.  To  activate this command, you
  3245.           should select blocks to hold cells being output, and activate this
  3246.           command.
  3247.  
  3248.                Currently, you cannot save your worksheet in Lotus release 1A
  3249.           format. Other than that, every thing is functional.
  3250.  
  3251.      File extension:
  3252.      ______________
  3253.                Lotus 123 release 1A  uses WKS  as its  file extension. SHEET
  3254.           uses SHT  as its  file extension. If you enter a file name in your
  3255.           file selector dialog box, you should  include the  file extension.
  3256.           The  file  extension  for  PART  is  PRT.  If you are printing the
  3257.           spreadsheet to disk, the  file extension  for this  file should be
  3258.           PRN.
  3259.  
  3260.      Load:
  3261.      ____
  3262.           There are three way to load a spreadsheet:
  3263.                -    From the menu title, choose "File"
  3264.                     Choose menu item "Load"
  3265.                     Select your file from the file selector box
  3266.                -    <Control-L>. Press <Control> and L key simultaneously
  3267.                     Select your file from the file selector box
  3268.                -    @load (This is a BASIC command).
  3269.  
  3270.      Save:
  3271.      ____
  3272.           There are three way to save a spreadsheet:
  3273.                -    From the menu title, choose "File"
  3274.                     Choose menu item "Save"
  3275.                     Enter your file in the file selector dialog box
  3276.                -    <Control-S>. Press <Control> and S key simultaneously
  3277.                     Enter your file in the file selector dialog box
  3278.                -    @save "filenmae" (This is a BASIC command.)
  3279.  
  3280.      Load PART:
  3281.      _________
  3282.                You can  merge those  cells that  are saved  with "Save PART"
  3283.           into your current  worksheet.  To  load  those  files,  you should
  3284.           select the menu item "Load PART" from the menu title "File".
  3285.  
  3286.  
  3287.  
  3288.  
  3289.                                      Page 40
  3290.  
  3291.  
  3292.  
  3293.  
  3294.  
  3295.  
  3296.  
  3297.  
  3298.  
  3299.  
  3300.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  3301.  
  3302.  
  3303.      Save Part:
  3304.      _________
  3305.                You can  save part of your worksheet to a file and then merge
  3306.           it  with  other  worksheet.  It  is  especially  useful  for BASIC
  3307.           programmer. They  may create  some BASIC  routines that are needed
  3308.           from file to file. Save them as PART and load them back  for other
  3309.           files. To  save part  of your  worksheet, you need to select those
  3310.           cells as blocks and activate the menu item  "Save PART".  The file
  3311.           extension for this kind of file is PRT.
  3312.  
  3313.      Lotus files:
  3314.      ___________
  3315.                In many ways, SHEET is quite similar to Lotus 123. But I must
  3316.           emphasize that I am not  writing  a  Lotus  clone.  Instead,  I am
  3317.           trying to  write a BASIC interpreter in a spreadsheet environment.
  3318.           Even though, SHEET can read Lotus  files,  you  may  not  be lucky
  3319.           enough  to  convert  all  your  existing  Lotus  files. SHEET will
  3320.           convert those functions it supports. When SHEET encounters problem
  3321.           in function convertion, it will stop loading the file. It can read
  3322.           Lotus 123 release 1A or 2 files.
  3323.                You may also notice that the converted SHT files are normally
  3324.           bigger than WKS files. There are two reason for that. First, I use
  3325.           a single data type  -- double  -- for  all constant  number. Lotus
  3326.           separates number  from integer  to double. An integer is two bytes
  3327.           long while a double is eight  bytes.  The  second  reason  is that
  3328.           Lotus stores formula in suffix order while SHEET stores formula in
  3329.           infix  order  (e.g.  3+4  is  in  infix  order,  its  suffix order
  3330.           representation is  3 4 +). Suffix order not only saves storage (in
  3331.           suffix order,  parenthesis  can  be  discarded  and  comma between
  3332.           parameters  can  be  discarded  too),  it  also  speeds up formula
  3333.           calculation. You may ask me why I use infix order? Well, it is not
  3334.           easy to write a BASIC interpreter using suffix order.
  3335.  
  3336.      Print:
  3337.      _____
  3338.                You can print your work sheet to a file or to printer. Before
  3339.                                                                       Before
  3340.           you print, please specify the block which you  want to  print. The
  3341.           you print, please specify the block which you  want to  print
  3342.           print routine  will print  those columns that fits on the margins.
  3343.           If some  columns on  the print  range are  not print  on the first
  3344.           pass, they will be printed on later passes.
  3345.                Note:
  3346.                Note      The information you enter for the PRINT DIALOG will
  3347.                          not be saved with  your spreadsheet  file. It means
  3348.                          you have  to type in your format each time you want
  3349.                          to print it.
  3350.  
  3351.  
  3352.                Here is an example showing how to print the block A1..E12
  3353.  
  3354.                Key       Mouse button   Effect              Mouse cursor
  3355.                                                               position
  3356.           ----------------------------------------------------------------
  3357.                                                             A1
  3358.                Control + Mouse button   A1 is inverted
  3359.                                                             E12
  3360.                Shift +   Mouse button   A1 through E12
  3361.                                         are inverted
  3362.  
  3363.                                      Page 41
  3364.  
  3365.  
  3366.  
  3367.  
  3368.  
  3369.  
  3370.  
  3371.  
  3372.  
  3373.  
  3374.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  3375.  
  3376.                <Control P>              PRINT dialog box
  3377.                                         display
  3378.                Change dialog box contents.
  3379.                <Return>  or Mouse button
  3380.                          on OK.
  3381.  
  3382.  
  3383.                Let us examine what  the components  of the  print dialog box
  3384.           mean.  If  you  want  to  print  your worksheet to disk instead of
  3385.           printer, enter D in  the box  after "Print  to (P)rinter/(D)isk:".
  3386.           Otherwise, enter  P. If  you want  to print the formula (including
  3387.           BASIC statement) of each  cell,  then  enter  Y  for  the question
  3388.           "Print  Formula  (Y)es/(N)o"".  Otherwise, enter N. NOTE: versions
  3389.           before 2.0 prints formula  row after  row. The  new version prints
  3390.           formula  column  after  column.  It  makes  printing BASIC program
  3391.           easier.
  3392.  
  3393.                                                        Right margin-->      
  3394.              <---------------------- Page width --------------------->
  3395.       ^       ********************************************************
  3396.       |       *         ^                                            *
  3397.       |       *         | Top margin and titles                      *
  3398.       |       *         v                                            *
  3399.       |       *        **************************************        *
  3400.       |       *        *                                    *        *
  3401.               *<------>*                                    *        *
  3402.       Page    * Left   *                                    *        *
  3403.       Length  * Margin *                                    *        *
  3404.               *        *                                    *        *
  3405.       |       *        *                                    *        *
  3406.       |       *        *                                    *        *
  3407.       |       *        *                                    *        *
  3408.       |       *        *                                    *        *
  3409.       |       *        *                                    *        *
  3410.       |       *        *                                    *        *
  3411.       |       *        *                                    *        *
  3412.       |       *        *                                    *        *
  3413.       |       *        **************************************        *
  3414.       |       *         ^                                            *
  3415.       |       *         | Bottom margin                              *
  3416.       |       *         v                                            *
  3417.       v       ********************************************************
  3418.                                                               
  3419.  
  3420.                If you want to test your output before you actually print it,
  3421.           you can enter the command:
  3422.  
  3423.                               @redirect to "prn:"
  3424.                               @print_block a1..g4,4,76
  3425.  
  3426.                The commands above will print row 1 to row 4 from column A to
  3427.           column G using left margin 4 and right margin 76  to your printer.
  3428.           You can  check the  result before  you actually print it. (That is
  3429.           useful because you cannot stop PRINT when it actually prints).
  3430.  
  3431.                                      Page 42
  3432.  
  3433.  
  3434.  
  3435.  
  3436.  
  3437.  
  3438.  
  3439.  
  3440.  
  3441.  
  3442.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  3443.  
  3444.                              PART III -- SHEET BASIC
  3445.  
  3446.           A spreadsheet is a  powerful computing  tool. It  is also  a handy
  3447.      environment for handling data. Yon can add, delete and change your data
  3448.      with ease, and the spreadsheet program modifies all the required places
  3449.      to reflect the changes.
  3450.  
  3451.           Let the  spreadsheet handle  your data and numurical calculations,
  3452.      and  let  the  BASIC  interpreter  do  the  rest.  SHEET  BASIC  can do
  3453.      calculations,   string   operations,   graphics  and  text  files.  The
  3454.      combination of spreadsheet and BASIC provides an ideal  environment for
  3455.      using your computer productively.
  3456.  
  3457.           The following is a brief explanation of each session of PART III.
  3458.  
  3459.      Cells,  Variables,   String:  This  chapter  introduces  the  new  cell
  3460.                          reference  method,  variables   and   their  naming
  3461.                          convention.
  3462.                               You cannot  assign a string to a variable, but
  3463.                          you can assign a  string to  a cell.  The rules for
  3464.                          accessing and operating strings are introduced too.
  3465.  
  3466.      Flow control Statements: These statements change the execution sequence
  3467.                          of BASIC commands. The commands include:
  3468.                          IF .. THEN .. ELSE, GOTO, GOSUB ..  RETURN, LOOP ..
  3469.                          EXIT IF .. ENDLOOP, FOR .. NEXT, and RUN
  3470.  
  3471.      I/O Statements:     REDIRECT TO, PRINT
  3472.  
  3473.      Miscellaneous  statements:  SAVE  SCREEN, RESTORE SCREEN, WAIT, DEFINE,
  3474.                          MESSAGE
  3475.  
  3476.      Text files:         GET_FILE, OPEN, CLOSE, INPUT, PRINT
  3477.  
  3478.      Worksheet commands: COPY, MOVE, ERASE, REFORMAT, SORT, SWAP
  3479.  
  3480.      Console commands:   CLS,  CURSORON,  CURSOROFF,  VIDEOHIGH,  VIDEONORM,
  3481.                          GOTOXY, INKEY, UNGET, INPUT
  3482.  
  3483.      Graphic commands:
  3484.           Setup commands:     WINDOW, VIEWPORT, SCALE, EXITGRAPH, CLEAR
  3485.           Line/Dot commands:  ATTRIBUTE,  LINE,  LINE_TO,  PLOT,  PLOT DATA,
  3486.                               SPLINE
  3487.           Turtlegraphics:     FORWARD, TURN, TURN_TO
  3488.           Axis commands:      MARKX, MARKY, LABELX, LABELY
  3489.           Text command:       PTEXT
  3490.           Miscellaneous:      MOUSE_POS
  3491.  
  3492.  
  3493.  
  3494.  
  3495.  
  3496.  
  3497.  
  3498.  
  3499.                                      Page 43
  3500.  
  3501.  
  3502.  
  3503.  
  3504.  
  3505.  
  3506.  
  3507.  
  3508.  
  3509.  
  3510.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  3511.  
  3512.                                Cells and Variables
  3513.  
  3514.      Cell reference with dimension:
  3515.      _____________________________
  3516.           A cell reference is a combination of column letter and row number.
  3517.      This type of access method is not enough for a programming language. In
  3518.      SHEET, you can use a  cell  as  a  BASE  and  move  it  horizontally or
  3519.      vertically by  appending two  numbers which  are separated by comma and
  3520.      embraced by "[" and "]". Each column letter has its own value. Column A
  3521.      is 1,  B is  2 and  so on.  For example,  A2[3,4]. A2 is the BASE whose
  3522.      coordinate is [1,2] and
  3523.  
  3524.                           A2[3,4]=[1,2]+[3,4]=[4,6]=D6.
  3525.  
  3526.           Here are some other examples:
  3527.  
  3528.                C1[4,7]   which is equivalent to  cell  G8.  C1  is  equal to
  3529.                          [3,1] and  C1[4,7]=[3,1]+[4,7] = [7,8]. Column G is
  3530.                          7. So the combination of this cell is G8.
  3531.                H123[-2,4] H123=[8,123]  and  H123[-2,4]  =  [8,123]+[-2,4] =
  3532.                          [6,127] or F127.
  3533.  
  3534.      Variables:
  3535.      _________
  3536.           Variables must be initialized before being used. You can define up
  3537.      to 150 variables. A variable name starts with an alpha  character which
  3538.      is  followed  by  alphanumeric  characters.  Up  to  15  characters are
  3539.      significant. A  variable  name  must  not  be  identical  with reserved
  3540.      keywords, built-in functions  and cell reference.
  3541.  
  3542.           examples:
  3543.                row=4          correct
  3544.                pi=3.1415      incorrect (PI is a predefined constant)
  3545.                a1=12          incorrect (it is cell A1)
  3546.                1and2          incorrect (the first character is not letter)
  3547.  
  3548.           There are  so many  keywords and  built-in functions,  how can one
  3549.      differentiate them from the other? Keywords are embraced by leading and
  3550.      trailing spaces. For example, IF is a keyword and when it is displayed,
  3551.      it is " IF ". A built-in function has a leading space  before the name.
  3552.      For example,  SIN(x) will  be displayed  as " SIN(X)". Variables do not
  3553.      have any leading or trailing space.
  3554.  
  3555.      Cell reference with variables
  3556.      _____________________________
  3557.            The whole worksheet can be viewed as a two dimensional array. You
  3558.      can access  any cell  by A1[c,r]  where c is the column number and r is
  3559.      the row number. 
  3560.           Not only you can access individual cell by using this  method, you
  3561.      can also  use it  for block.  For example,  assume that  you store your
  3562.      square matrix in cells a1..c3 and you want to store the inverse of this
  3563.      matrix to d1..f3. You can use the following program to do this.
  3564.  
  3565.      ! matrix(d1,inverse[a1..c3])
  3566.      ! end 
  3567.  
  3568.           Assume that  you need  to solve another square matrix in which you
  3569.  
  3570.                                      Page 44
  3571.  
  3572.  
  3573.  
  3574.  
  3575.  
  3576.  
  3577.  
  3578.  
  3579.  
  3580.  
  3581.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  3582.  
  3583.      store it in cells a1..d4. You can easily change the  argument of matrix
  3584.      to:
  3585.  
  3586.      ! matrix(e1,inverse[a1..d4)
  3587.  
  3588.      If  you  keep  using  this  method  to solve square matrix in different
  3589.      sizes, you may find it is  clumsy and  easy to  make mistakes.  Here is
  3590.      another program  that makes  the whole process of changing a lot easier
  3591.      for you and less error prone.
  3592.  
  3593.      !n=3
  3594.      ! matrix(a1[n,0],invers[a1..a1[n-1,n-1])
  3595.      ! end 
  3596.  
  3597.      n=3 so a1[3,0]=[1,1]+[3,0]=[4,1]=d1 and 
  3598.                a1[n-1,n-1]=[1,1][2,2]=[3,3]=c3.
  3599.  
  3600.      All you need to change is the constant n.
  3601.  
  3602.      String
  3603.      ______
  3604.           You may store numerical data or TEXT string in a cell. To access a
  3605.      cell  as  a  string,  you  should  add  the "$" at the end of each cell
  3606.      reference. For example:
  3607.                                  A1$,  A1[i,j]$
  3608.  
  3609.           String  operators   for  comparisons,   concatenation  and  string
  3610.      functions  are  added  for  BASIC users. REMEMBER, string functions and
  3611.      concatenation are available  only  in  BASIC  statements  and commands.
  3612.      Currently, you  can assign  string to  cells but not the 150 variables.
  3613.      Two predefined string variables  are provided  for file  name and input
  3614.      buffer. They  are FILENAME$  and BUF$.  You can use them but you cannot
  3615.      assign new value to  them. FILENAME$  is changed  whenever you  use the
  3616.      file item  selector and  BUF$ is  changed whenever  you use the command
  3617.      INPUT. For  more details,  please refer  to "Text  files" for GET_FILE,
  3618.      INPUT #n and "Console:" for INPUT.
  3619.  
  3620.           If an  empty cell  is referred  as a string, a null string will be
  3621.      returned. If a cell with number is referred as a string, then  a string
  3622.      that is  exactly being displayed for that cell will be returned. If the
  3623.      cell is a TEXT string, a string excluding the leading character will be
  3624.      returned. The  leading character  for a TEXT string is one of ' " ^ and
  3625.      \.
  3626.  
  3627.           If you are assigning a string to a  cell, and  if the  string does
  3628.      not contain  one of those leading character, then the default character
  3629.      defined in "TEXT justification" of menu item "Defaults" will be used as
  3630.      the leading character for that cell.
  3631.           WARNING: DO NOT MAKE ANY STRING LONGER THAN 249 CHARACTERS.
  3632.  
  3633.      String operators:
  3634.      String operators
  3635.           +:   string  concatenation.  For  example  "Thi"+"s  a  test" will
  3636.                return a string "This is a test".
  3637.           =:   string   assignment   or   string   equal   comparison.  E.g.
  3638.                !a1$="^123": END.  or !if a1$=b1$ then ...
  3639.  
  3640.                                      Page 45
  3641.  
  3642.  
  3643.  
  3644.  
  3645.  
  3646.  
  3647.  
  3648.  
  3649.  
  3650.  
  3651.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  3652.  
  3653.           <>, >, <, =>, >=, =<, <=
  3654.                string  comparisons  for  not  equal, greater, less, equal or
  3655.                greater and equal or less than.
  3656.  
  3657.  
  3658.  
  3659.  
  3660.  
  3661.  
  3662.  
  3663.  
  3664.  
  3665.  
  3666.  
  3667.  
  3668.  
  3669.  
  3670.  
  3671.  
  3672.  
  3673.  
  3674.  
  3675.  
  3676.  
  3677.  
  3678.  
  3679.  
  3680.  
  3681.  
  3682.  
  3683.  
  3684.  
  3685.  
  3686.  
  3687.  
  3688.  
  3689.  
  3690.  
  3691.  
  3692.  
  3693.  
  3694.  
  3695.  
  3696.  
  3697.  
  3698.  
  3699.  
  3700.  
  3701.  
  3702.  
  3703.  
  3704.  
  3705.  
  3706.  
  3707.  
  3708.                                      Page 46
  3709.  
  3710.  
  3711.  
  3712.  
  3713.  
  3714.  
  3715.  
  3716.  
  3717.  
  3718.  
  3719.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  3720.  
  3721.                              Flow control Statements
  3722.  
  3723.      IF .. THEN .. ELSE ..
  3724.           Syntax:
  3725.                IF conditionn THEN statements:ELSE statements
  3726.  
  3727.           Description:
  3728.                This statement is used to make  a decision  regarding program
  3729.                flow based on the result returned by an expression.
  3730.  
  3731.           Example:
  3732.                IF A1=12 THEN A2=20:ELSE A2=30
  3733.  
  3734.           NOTE: The following statements are not valid:
  3735.                     IF A1=12 THEN G3:ELSE GOTO G4
  3736.                     IF A1=12 GOTO G3
  3737.           If you  have used  traditional BASICs  before, you would know that
  3738.           you can write "IF A1=12 THEN 120:ELSE GOTO 130" and "IF A1=12 GOTO
  3739.           120" They  are not  valid in  SHEET. Instead, you must change them
  3740.           to:
  3741.                     IF A1=12 THEN GOTO G3:ELSE GOTO G4
  3742.                     IF A1=12 THEN GOTO G3
  3743.  
  3744.      GOTO
  3745.           Syntax:
  3746.                GOTO cell.
  3747.  
  3748.           Description:
  3749.                This  statement  is  used  to  branch  unconditionally  to  a
  3750.                specified cell.
  3751.  
  3752.           Example:
  3753.                GOTO A1
  3754.  
  3755.      GOSUB .. RETURN
  3756.           Syntax:
  3757.                GOSUB cell
  3758.                ...
  3759.                RETURN
  3760.  
  3761.           Description:
  3762.                These statements uses in pair for branching to, and returning
  3763.                from a subroutine.
  3764.  
  3765.      LOOP .. EXIT IF .. ENDLOOP
  3766.           Syntax:
  3767.                LOOP
  3768.                ...
  3769.                EXIT IF condition
  3770.                ....
  3771.                ENDLOOP
  3772.  
  3773.           Description:
  3774.                Those commands are used to execute a series  of statements in
  3775.  
  3776.                                      Page 47
  3777.  
  3778.  
  3779.  
  3780.  
  3781.  
  3782.  
  3783.  
  3784.  
  3785.  
  3786.  
  3787.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  3788.  
  3789.                a loop until some conditions are true. Condition is a logical
  3790.                expression which may be  either  TRUE  or  FALSE.  Within the
  3791.                LOOP, multiple EXIT IFs are allowed. It is adviced not to use
  3792.                GOTO statement to break the loop.
  3793.           Example:
  3794.                The following example assigns 1 to 20 to cell A1 through A20.
  3795.                     R=0
  3796.                     LOOP
  3797.                     A1[0,R]=R+1
  3798.                     R = R+1
  3799.                     EXIT IF R=20
  3800.                     ENDLOOP
  3801.  
  3802.      FOR .. NEXT
  3803.           Syntax:
  3804.                FOR assignment TO expression [STEP expression]
  3805.                ...
  3806.                NEXT variable_being_assigned
  3807.  
  3808.           Description:
  3809.                These commands are used to execute a series  of statements in
  3810.                a  definite  number  of  times.  STEP is optional. If no STEP
  3811.                value being provided, it is assumed to be one. In other BASIC
  3812.                interpreters, NEXT  I,J means: increases value of I, when the
  3813.                              _________
  3814.                FOR loop for I is done, then increases  value of  J. You must
  3815.                use NEXT  I: NEXT J in SHEET BASIC. The number of nesting FOR
  3816.                    _______________
  3817.                loops is infinite.
  3818.  
  3819.      RUN
  3820.           Syntax:
  3821.                RUN cell
  3822.  
  3823.           Description:
  3824.                RUN is similar to GOTO. The only difference is that  RUN will
  3825.                initialize the runtime stack and reset the symbol table. Most
  3826.                of the time, RUN is used to execute BASIC codes starting from
  3827.                a specified  cell. If  the cell is C1, you should enter "@run
  3828.                c1" in the editing buffer.
  3829.  
  3830.  
  3831.  
  3832.  
  3833.  
  3834.  
  3835.  
  3836.  
  3837.  
  3838.  
  3839.  
  3840.  
  3841.  
  3842.  
  3843.  
  3844.  
  3845.  
  3846.                                      Page 48
  3847.  
  3848.  
  3849.  
  3850.  
  3851.  
  3852.  
  3853.  
  3854.  
  3855.  
  3856.  
  3857.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  3858.  
  3859.                                  I/O Statements
  3860.  
  3861.      REDIRECT TO
  3862.           Syntax:
  3863.                REDIRECT TO "file"
  3864.  
  3865.           Description:
  3866.                     This statement changes  the  output  path  of subsequent
  3867.                PRINT  commands  to  the  specified  file.  There  are  a few
  3868.                predefined files. prn: is the printer,  con: is  your monitor
  3869.                                  ____                  ____
  3870.                and aux:  is the rs-232 port. Otherwise, they are disk files.
  3871.                    ____
  3872.                The default file is  con:. Except  con:, all  the file output
  3873.                are buffered. It means you may not get instant response.
  3874.                     If  you  redirect  the  output  to  printer  and if your
  3875.                printer is not on, an alert box will  show up.  If you choose
  3876.                "Quit", the  BASIC program being executed will be stopped. If
  3877.                you choose "Continue",  the  subsequent  PRINT  commands will
  3878.                output to the file prior to REDIRECT TO command. Most likely,
  3879.                it is con:. You should turn your printer on before you choose
  3880.                "Try again".
  3881.  
  3882.           EXAMPLE:
  3883.                REDIRECT TO "prn:"
  3884.  
  3885.  
  3886.      PRINT statement
  3887.           Syntax:
  3888.                PRINT cell/cell$/number/string[,/;...]
  3889.  
  3890.           Description:
  3891.                     This command  prints numeric  or string data to the file
  3892.                specified by REDIRECT  TO  command.  Implicitly,  it  is your
  3893.                monitor. If no data following the PRINT command, a blank line
  3894.                will be printed.  String  data  must  be  enclosed  by double
  3895.                quotation  marks.   Each  datum  can  be  a  cell  reference,
  3896.                variable, string or number. If more  than one  datum is going
  3897.                to  print,  each  of  them  should  be  separated by comma or
  3898.                semicolon. If you are using comma to separated  two data, the
  3899.                second data  will be  aligned to  the next TAB position. Each
  3900.                TAB is 10 characters wide.
  3901.                     If you are printing  cell content,  the format specified
  3902.                in  that  cell  is  used  exactly as display. If the cell you
  3903.                intended to print contains TEXT string, you should add "$" at
  3904.                the end  of the  cell reference.  Otherwise, you will print a
  3905.                cell with zero.
  3906.                     If  a  number  is  being  printed,  the  number  will be
  3907.                surrounded  by  a  leading  space  and  a trailing space. The
  3908.                output format of variables is similar to a  number.If you are
  3909.                printing  string,   the  text   inside  the  embraced  double
  3910.                quotation marks will be outputed.
  3911.                     While you are printing,  you  can  use  <Control  S> and
  3912.                <Control  Q>  to  suspend  and resume your display. BUT don't
  3913.                                                                    _________
  3914.                press <Control C> to stop your PRINT session. If you do press
  3915.                _____________________________________________________________
  3916.                <Control C>  while PRINT  command is printing on console, YOU
  3917.                _____________________________________________________________
  3918.  
  3919.                                      Page 49
  3920.  
  3921.  
  3922.  
  3923.  
  3924.  
  3925.  
  3926.  
  3927.  
  3928.  
  3929.  
  3930.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  3931.  
  3932.                WILL GET back to desktop and you need to reboot the system to
  3933.                _____________________________________________________________
  3934.                use SHEET. UES <ESC> to stop your BASIC program.
  3935.                ________________________________________________
  3936.  
  3937.           Example:
  3938.                PRINT a1,12;b1$;20;"This is a test"
  3939.  
  3940.  
  3941.  
  3942.  
  3943.  
  3944.  
  3945.  
  3946.  
  3947.  
  3948.  
  3949.  
  3950.  
  3951.  
  3952.  
  3953.  
  3954.  
  3955.  
  3956.  
  3957.  
  3958.  
  3959.  
  3960.  
  3961.  
  3962.  
  3963.  
  3964.  
  3965.  
  3966.  
  3967.  
  3968.  
  3969.  
  3970.  
  3971.  
  3972.  
  3973.  
  3974.  
  3975.  
  3976.  
  3977.  
  3978.  
  3979.  
  3980.  
  3981.  
  3982.  
  3983.  
  3984.  
  3985.  
  3986.  
  3987.  
  3988.  
  3989.                                      Page 50
  3990.  
  3991.  
  3992.  
  3993.  
  3994.  
  3995.  
  3996.  
  3997.  
  3998.  
  3999.  
  4000.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  4001.  
  4002.                             Miscellaneous statements
  4003.  
  4004.           If  you  print  to  console,  your current display may be garbled.
  4005.           Therefore, you  need  to  save  your  screen  before  printing and
  4006.           restore it after you are done.
  4007.  
  4008.      SAVE SCREEN
  4009.           Syntax:
  4010.                SAVE SCREEN
  4011.  
  4012.           Description:
  4013.                     Save current  display to  SCREEN reserved  area. That is
  4014.                the same area that  is used  for FAST  screen update.  If you
  4015.                deny to reserve 32K for fast screen update, you may crash the
  4016.                system when you use this command.
  4017.  
  4018.      RESTORE SCREEN
  4019.           Syntax:
  4020.                RESTORE SCREEN
  4021.  
  4022.           Description:
  4023.                Restore the screen to the old display.
  4024.  
  4025.      WAIT
  4026.           Syntax:
  4027.                WAIT
  4028.                WAIT #
  4029.  
  4030.           Description:
  4031.                     This statement suspends the execution of BASIC commands.
  4032.                # means an integer number. If no number follows WAIT, it will
  4033.                print "Press return to continue ..." on console  and you must
  4034.                press  <Return>  key  to  resume  its operations. The printed
  4035.                message will damage your display. Hence, you should save your
  4036.                screen before calling WAIT.
  4037.                     If WAIT  followed by  an integer x, then the system will
  4038.                wait for x seconds.
  4039.  
  4040.           Example:
  4041.                WAIT 5         (System suspends for 5 seconds)
  4042.  
  4043.      DEFINE
  4044.           Syntax:
  4045.                DEFINE fname(parameters) = expression
  4046.  
  4047.           Description:
  4048.                     This statement let user define its  own functions. Fname
  4049.                is the  function name. Its naming convention follows the rule
  4050.                for naming variable. You can put up to 9 parameters  for each
  4051.                user  function.  Each  parameter  is  a variable separated by
  4052.                comma. Each DEFINE statement  must occupy  a single  cell and
  4053.                user  defined  function  is  useful for numerical calculation
  4054.                only.
  4055.  
  4056.  
  4057.                                      Page 51
  4058.  
  4059.  
  4060.  
  4061.  
  4062.  
  4063.  
  4064.  
  4065.  
  4066.  
  4067.  
  4068.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  4069.  
  4070.      MESSAGE
  4071.           Syntax:
  4072.                MESSAGE "text"
  4073.  
  4074.           Description:
  4075.                     This  command  uses  the  GEM  alert  box  to  display a
  4076.                message. "text"  can be  a string of up to 5 lines. Each line
  4077.                is separated by "|" and the length of each line should not be
  4078.                bigger than 40.
  4079.  
  4080.           Example:
  4081.                MESSAGE "Hello|World"
  4082.  
  4083.      EXAMPLE: Address label program
  4084.      EXAMPLE
  4085.           Assume  that   you  store   your  address   data  in  the  current
  4086.           spreadsheet. Column A holds the  Last  name.  Column  B  holds the
  4087.           First name. Column C holds the address and D,E,F holds City, State
  4088.           and Zip respectively. The  data starts  from row  3. The following
  4089.           program will  print the  data in your address sheet to the address
  4090.           label for handling mails.  Assume  the  program  stores  from cell
  4091.           G1..G10 and you run it by "@run g1".
  4092.  
  4093.      G1    : ! REDIRECT  TO "prn:" 
  4094.      G2    : !R=0: SAVE  SCREEN  
  4095.      G3    : ! LOOP 
  4096.      G4    : ! EXIT  IF  ISEMPTY(A3[0,R]): PRINT  
  4097.      G5    : ! PRINT A3[1,R]$;A3[0,R]$ 
  4098.      G6    : ! PRINT A3[2,R]$ 
  4099.      G7    : ! PRINT A3[3,R]$;A3[4,R]$;A3[5,R]$ 
  4100.      G8    : ! PRINT : PRINT :R=R+1 
  4101.      G9    : ! ENDLOOP : WAIT  
  4102.      G10   : ! RESTORE  SCREEN  
  4103.  
  4104.  
  4105.  
  4106.  
  4107.  
  4108.  
  4109.  
  4110.  
  4111.  
  4112.  
  4113.  
  4114.  
  4115.  
  4116.  
  4117.  
  4118.  
  4119.  
  4120.  
  4121.  
  4122.  
  4123.  
  4124.  
  4125.  
  4126.                                      Page 52
  4127.  
  4128.  
  4129.  
  4130.  
  4131.  
  4132.  
  4133.  
  4134.  
  4135.  
  4136.  
  4137.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  4138.  
  4139.                                    Text files
  4140.  
  4141.                SHEET should  be the first spreadsheet which has the commands
  4142.           for you to access any TEXT  files. The  command is  line oriented.
  4143.           These commands  are intended  for people  who need to acquire data
  4144.           from other  sources.  There  are  two  constant  strings  that are
  4145.           related to some of the Text file commands. FILENAME$ is a constant
  4146.           string that can be changed by file item  selecto dialog  box. BUF$
  4147.           is a constant string that is modified by any INPUT statement.
  4148.  
  4149.                Using the file commands and string functions, you can do some
  4150.           thing that is impossible for user of other spreadsheet programs.
  4151.  
  4152.      GET_FILE
  4153.           Syntax:
  4154.                GET_FILE def_search, name$
  4155.  
  4156.           Description:
  4157.                     Use the  file  item  selector  to  find  the  file name.
  4158.                Def_search is  the default  search string. It can be a string
  4159.                with wild characters.  For  example  "\*.SHT".  name$  can be
  4160.                FILENAME$ or a cell reference.
  4161.  
  4162.           Example:
  4163.                GET_FILE "\*.*",filename$
  4164.                GET_FILE "\*.txt",a1$
  4165.  
  4166.      OPEN
  4167.           Syntax:
  4168.                OPEN "o",#n,filename$
  4169.                OPEN "i",#n,a1$
  4170.  
  4171.           Description:
  4172.                     Open a  file for  input or  output. "o" means output and
  4173.                "i" for input. #n  means the  channel number.  N should  be a
  4174.                number  from  0  to  9.  Filename  can be FILENAME$ or a cell
  4175.                reference.
  4176.  
  4177.           Example:
  4178.                OPEN "o",#1,FILENAME$
  4179.                OPEN "i",#2,"test.txt"
  4180.  
  4181.      CLOSE
  4182.           Syntax:
  4183.                CLOSE #n[,#m,...]
  4184.  
  4185.           Description:
  4186.                     Close opened files. #n , #m are the channel number. They
  4187.                should be  in the  range of  0 to  9. If  you try to close an
  4188.                unopened file, you will get an error message "Cannot close an
  4189.                unopened file".
  4190.  
  4191.           Example:
  4192.                CLOSE #1
  4193.  
  4194.                                      Page 53
  4195.  
  4196.  
  4197.  
  4198.  
  4199.  
  4200.  
  4201.  
  4202.  
  4203.  
  4204.  
  4205.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  4206.  
  4207.  
  4208.      INPUT #n
  4209.           Syntax:
  4210.                INPUT #n,buf$
  4211.  
  4212.           Description:
  4213.                     Read  a  line  from  the  input  file. #n is the channel
  4214.                number. buf$ can be BUF$ or a cell reference.  If the channel
  4215.                number being  referred is an output file or an unopened file,
  4216.                you will get an error message "Channel number error".
  4217.  
  4218.           Example:
  4219.                INPUT #1, BUF$
  4220.                INPUT #1, a1$
  4221.  
  4222.      PRINT #n
  4223.           Syntax:
  4224.                PRINT #n, cell/cell$/string/number[,/;....]
  4225.  
  4226.           Description:
  4227.                     PRINT #n is similar to PRINT  except that  PRINT outputs
  4228.                to  the  file  specified  by  REDIRECT  TO  (implicitly  your
  4229.                terminal). PRINT  #n  outputs  to  the  channel  number being
  4230.                opened by OPEN command.
  4231.  
  4232.           Example:
  4233.                Assume that  cell a1$="This  is a  test" and b1=12.34 and the
  4234.                widths of column A and B are 9.
  4235.                PRINT #1,a1;b1      ==> "       0    12.34 " to #1
  4236.                PRINT #1,a1$;b1     ==> "This is a test   12.34 " to #1
  4237.  
  4238.  
  4239.  
  4240.  
  4241.  
  4242.  
  4243.  
  4244.  
  4245.  
  4246.  
  4247.  
  4248.  
  4249.  
  4250.  
  4251.  
  4252.  
  4253.  
  4254.  
  4255.  
  4256.  
  4257.  
  4258.  
  4259.  
  4260.  
  4261.  
  4262.                                      Page 54
  4263.  
  4264.  
  4265.  
  4266.  
  4267.  
  4268.  
  4269.  
  4270.  
  4271.  
  4272.  
  4273.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  4274.  
  4275.                                Worksheet commands
  4276.  
  4277.                SHEET BASIC is part of SHEET  -- the  spreadsheet program. It
  4278.           is more convenient if you can use some of those worksheet commands
  4279.           to handle data in your BASIC  program. This  new version  of SHEET
  4280.           provides  some  of  the  essential  worksheet  commands for you to
  4281.           incorporate  with  your  program.  They  are  COPY,  MOVE,  ERASE,
  4282.           REFORMAT, SORT  and SWAP. SORT and SWAP are new commands for SHEET
  4283.           too. Currently, they can be activated by BASIC commands only. They
  4284.           work fine  with cells  whose formula  do not refer to other cells.
  4285.           That is because the  cell  references  in  those  formula  are not
  4286.           updated  when  you  SWAP  them.  Next  release  should remove this
  4287.           restriction.
  4288.  
  4289.      COPY
  4290.           Syntax:
  4291.                COPY block1, block2
  4292.  
  4293.           Description:
  4294.                     Copy block1 to block2. A block can be a single cell or a
  4295.                rectangle portion  of the worksheet. The COPY command follows
  4296.                the rule for COPYing cells by <Ctrl-C>.
  4297.  
  4298.           Example:
  4299.                COPY a1..b3, c1
  4300.  
  4301.      MOVE
  4302.           Syntax:
  4303.                MOVE block1, block2
  4304.  
  4305.           Description:
  4306.                     Move block1 to block2.  It  is  similar  to  the command
  4307.                <Ctrl-M>.
  4308.  
  4309.           Example:
  4310.                MOVE a1..b3, c1
  4311.  
  4312.      ERASE
  4313.           Syntax:
  4314.                ERASE block1[,block2,...]
  4315.  
  4316.           Description:
  4317.                     Erase portion  of the worksheet specified by the blocks.
  4318.                Up to 18 blocks can be erased at one time.
  4319.  
  4320.           Example:
  4321.                ERASE a1..b3,c1..d3
  4322.  
  4323.      REFORMAT
  4324.           Syntax:
  4325.                REFORMAT FORMAT,block1[,block2,...]
  4326.  
  4327.           Description:
  4328.                     Reformat portion of the worksheet. Up  to 18  blocks can
  4329.  
  4330.                                      Page 55
  4331.  
  4332.  
  4333.  
  4334.  
  4335.  
  4336.  
  4337.  
  4338.  
  4339.  
  4340.  
  4341.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  4342.  
  4343.                be reformat at one time. FORMAT is a string which consists of
  4344.                two part -- format and decimal places. A  format can  be "$",
  4345.                ",",  "F",  "S",  "D1",  "D2",  "D3". "$" for DOLLAR, "," for
  4346.                COMMA, "F" for FIXED, "S" for SCINETIFIC and "D1", "D2", "D3"
  4347.                for DATE1,  DATE2, and  DATE3 respectively. No decimal places
  4348.                should follow "D1","D2" and "D3".
  4349.  
  4350.           Example:
  4351.                REFORMAT "$2",A1..B3
  4352.                     (reformat a1..b3 for dollar and 2 decimal places)
  4353.                REFORMAT "D1", C1..C12
  4354.                     (reformat C1..c12 for Date1 format)
  4355.  
  4356.      SORT
  4357.           Syntax:
  4358.                SORT "A",block, cell1[,cell2,...]
  4359.                SORT "D",block, cell1[,cell2,...]
  4360.  
  4361.           Description:
  4362.                     Sort followed by "A" means sort block in ascending order
  4363.                and "D" for descending order. Only the block will be affected
  4364.                by the sort command. Cell1 points to the first column that is
  4365.                used for  comparison. Up  to 6  of these cells can be used as
  4366.                criteria for comparisons. In  comparison,  an  empty  cell is
  4367.                smaller  than  a  cell  with  numerical value and a cell with
  4368.                numerical value is smaller than a cell contains  TEXT string.
  4369.                If the  column being  compared consists  of BASIC statements,
  4370.                SORT will be stopped. Currently,  SORT  does  not  modify the
  4371.                formula on  each cell being affected. You may have trouble in
  4372.                sorting cells whose formula refers to other cells.
  4373.  
  4374.           Example:
  4375.                SORT "A",A1..B3,A1
  4376.  
  4377.      SWAP
  4378.           Syntax:
  4379.                SWAP cell1, cell2
  4380.  
  4381.           Description:
  4382.                     This command  swaps cell1  with cell2.  It swaps between
  4383.                two cells.  If you  want to  swap a  row with  other row, you
  4384.                should use a FOR  loop to  do it  one by  one. Again,  it has
  4385.                problem with cell whose formula refers to other cell.
  4386.  
  4387.           Example:
  4388.                SWAP a1,b2
  4389.  
  4390.  
  4391.  
  4392.  
  4393.  
  4394.  
  4395.  
  4396.  
  4397.  
  4398.                                      Page 56
  4399.  
  4400.  
  4401.  
  4402.  
  4403.  
  4404.  
  4405.  
  4406.  
  4407.  
  4408.  
  4409.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  4410.  
  4411.                                 Console commands
  4412.                                 ________________
  4413.                The  Atari  monitor  emulates  the VT52 terminal. You can use
  4414.           those VT52 commands to control your output. This  version of SHEET
  4415.           provides some  of the  VT52 commands  in the SHEET BASIC. They are
  4416.           CLS, CURSORON, CURSOROFF,  VIDEOHIGH,  VIDEONORM  and  GOTOXY. One
  4417.           function  and  two  commands  for  reading  keyboard  entries  are
  4418.           provided. They are INKEY, UNGET and INPUT.
  4419.  
  4420.                Screen coordinate: (1,1) is the upper  left-corner, (80,1) is
  4421.           the  upper  right-corner,  (1,25)  is  the  bottom left-corner and
  4422.           (80,25) is the bottom right-corner.
  4423.  
  4424.      CLS
  4425.           Syntax:
  4426.                CLS
  4427.  
  4428.           Description:
  4429.                Clear the current screen and move the cursor  to the position
  4430.                1,1.
  4431.  
  4432.      CURSORON
  4433.           Syntax:
  4434.                CURSORON
  4435.  
  4436.           Description:
  4437.                Makes the screen cursor visible.
  4438.  
  4439.      CURSOROFF
  4440.           Syntax:
  4441.                CURSOROFF
  4442.  
  4443.           Description:
  4444.                Turns the screen cursor off.
  4445.  
  4446.      VIDEOHIGH
  4447.           Syntax:
  4448.                VIDEOHIGH
  4449.  
  4450.           Description:
  4451.                Makes the subsequent output characters in reverse color
  4452.  
  4453.      VIDEONORM
  4454.           Syntax:
  4455.                VIDEONORM
  4456.  
  4457.           Description:
  4458.                Makes the subsequent output characters in normal color
  4459.  
  4460.      GOTOXY
  4461.           Syntax:
  4462.                GOTOXY x,y
  4463.  
  4464.           Description:
  4465.                     Moves the  screen cursor  to position  x,y. x  is in the
  4466.  
  4467.                                      Page 57
  4468.  
  4469.  
  4470.  
  4471.  
  4472.  
  4473.  
  4474.  
  4475.  
  4476.  
  4477.  
  4478.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  4479.  
  4480.                range of 1 to 80 and y is in the range of 1 to 25.
  4481.  
  4482.      INKEY
  4483.           Syntax:
  4484.                a=INKEY
  4485.  
  4486.           Description:
  4487.                     It is a function that returns the ASCII number of  a key
  4488.                being pressed. If no key or special keys are being pressed -1
  4489.                will be returned. Arrow keys for  Up, Down,  Left, Right have
  4490.                value of  129,130,131 and  132 respectively . Arrow keys with
  4491.                Shift  keys  for  Up,  Down,  Left,  Right  have   values  of
  4492.                133,134,135 and 136.
  4493.  
  4494.           Example:
  4495.                A=INKEY
  4496.  
  4497.      UNGET
  4498.           Syntax:
  4499.                UNGET x
  4500.  
  4501.           Description:
  4502.                Put x back to the input stream for later INPUT uses.
  4503.  
  4504.           Example:
  4505.                A=INKEY:.... :UNGET a
  4506.  
  4507.      INPUT
  4508.           Syntax:
  4509.                INPUT buf$
  4510.  
  4511.           Description:
  4512.                     buf$  can  be  either  BUF$  or  a  cell reference. This
  4513.                routine calls the standard C function gets to get your input.
  4514.                If  you  UNGET  a  character before calling this command, the
  4515.                UNGET character cannot be altered or displayed but it will be
  4516.                the first character in your buf$.
  4517.  
  4518.  
  4519.  
  4520.  
  4521.  
  4522.  
  4523.  
  4524.  
  4525.  
  4526.  
  4527.  
  4528.  
  4529.  
  4530.  
  4531.  
  4532.  
  4533.  
  4534.  
  4535.                                      Page 58
  4536.  
  4537.  
  4538.  
  4539.  
  4540.  
  4541.  
  4542.  
  4543.  
  4544.  
  4545.  
  4546.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  4547.  
  4548.                                 Graphic commands
  4549.                                 ________________
  4550.  
  4551.           Your  monitor  can  be  used  to  display pictures. A picture is a
  4552.      collection of picture elements (pixels). Some  people prefer  to call a
  4553.      pixel a  dot. Normal  graphic commands in other BASIC languages provide
  4554.      you a mean to change each pixel in your display.  The addressing method
  4555.      they used  are called  Raster coordinate.  The left top-corner is (0,0)
  4556.      and the right bottom-corner  is (639,399),  (639,199) or  (319,199) for
  4557.      high, medium and low resolution.
  4558.           In real world, we are dealing with Cartesian coordinate instead of
  4559.      Raster coordinate. The left bottom-corner is  the minimal  point we can
  4560.      use  for  display  and  the  right top-corner is the maximal point. The
  4561.      graphic commands provided by SHEET BASIC  use the  Cartesian coordinate
  4562.      and those commands will translate Cartesian points to pixels.
  4563.           SHEET  BASIC  is  not  the  first  BASIC interpreter which provide
  4564.      scientific graphics (at least True BASIC is a few years earlier). But I
  4565.      think it  is the first BASIC provides cubic spline curves. Cubic spline
  4566.      is a method scientists use to draw smooth curves.
  4567.           The graphic commands are highly relocatable  and they  work on any
  4568.      resolution. Hence,  it is  possible to use 16 colors to plot your graph
  4569.      in low resolution.
  4570.           The graphics commands are separated into the following categories:
  4571.                Setup commands:
  4572.                Setup commands:     WINDOW  or  VIEWPORT,  SCALE,  EXITGRAPH,
  4573.                                    CLEAR
  4574.                Line/Dot commands:
  4575.                Line/Dot commands:  ATTRIBUTE,  LINE,   LINE_TO,  PLOT,  PLOT
  4576.                                    DATA, SPLINE
  4577.                Turtlegraphics:
  4578.                Turtlegraphics      FORWARD, TURN, TURN_TO
  4579.                Axis commands:
  4580.                Axis commands       MARKX, MARKY, LABELX, LABELY
  4581.                Text command:
  4582.                Text command:       PTEXT
  4583.                Miscellaneous:
  4584.                Miscellaneous:      MOUSE_POS
  4585.  
  4586.           CONVENTION:
  4587.           CONVENTION     Optional  parameters  are  bracketed.   #  means  a
  4588.                          number. (x,y),  (x1,y1) and (x2,y2) are measured in
  4589.                          Cartesian coordinate. An  r  added  before  x  or y
  4590.                          means the point is in Raster coordinate.
  4591.  
  4592.  
  4593.  
  4594.  
  4595.  
  4596.  
  4597.  
  4598.  
  4599.  
  4600.  
  4601.  
  4602.  
  4603.  
  4604.  
  4605.  
  4606.  
  4607.  
  4608.  
  4609.  
  4610.  
  4611.                                      Page 59
  4612.  
  4613.  
  4614.  
  4615.  
  4616.  
  4617.  
  4618.  
  4619.  
  4620.  
  4621.  
  4622.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  4623.  
  4624.  
  4625.      Setup commands:
  4626.      ______________
  4627.           WINDOW or  VIEWPORT defines  the part of the screen being used for
  4628.      graphic output. They are the  only  commands  whose  parameters  are in
  4629.      Raster coordinate. SCALE defines the scaling factors that translate the
  4630.      Cartesian corrdinate data into location on  your display.  CLEAR cleans
  4631.      up the  area defined  by WINDOW or VIEWPORT. WINDOW and VIEWPORT change
  4632.      the clipping area. The last command after your graph is  done should be
  4633.      EXITGRAPH  which  resets  the  clipping  area  to  the  current window.
  4634.      Otherwise, you may have an illusion that your system is locked. In case
  4635.      you  feel  your  system  is  locked,  you should try <Esc> first to see
  4636.      whether a BASIC program  is running.  If the  system is  still lock-up,
  4637.      enter the  command "@EXITGRAPH" in blind and you should have the system
  4638.      back.
  4639.  
  4640.           WINDOW:
  4641.           ______
  4642.                Syntax:
  4643.                     WINDOW [# [,rx1,ry1,rx2,ry2] ]
  4644.  
  4645.                Description:
  4646.                          If no parameter provides for this command, then the
  4647.                     current window will be used for graphic output.
  4648.                          SHEET supports up to 4 windows. Each window has its
  4649.                     own number ranging from 1 to 4. This  number corresponds
  4650.                     to the  number you  press ALT-1,  ALT-2, ALT-3 or ALT-4.
  4651.                     So, you can use any window for graphics output.
  4652.                          If  raster  parameters  provide,  then  the  window
  4653.                     specified will  be resized  to those coordinates and the
  4654.                     work area of  that  window  will  be  used  for graphics
  4655.                     output. If  a window changes it size, AES will ask SHEET
  4656.                     to redraw it. So, you may need to run your program twice
  4657.                     to get the graph.
  4658.                          If the window number specified has not been opened,
  4659.                     then you won't see the graph, but the  BASIC interpreter
  4660.                     will not stop.
  4661.  
  4662.                Examples:
  4663.                     WINDOW                   using the current window
  4664.                     WINDOW 1                 using window 1
  4665.                     WINDOW 1,0,20,350,120    reposition and resize window 1
  4666.  
  4667.                Hints:
  4668.                          If your  program involves a lot of calculation, and
  4669.                     you don't want to  run  the  program  twice  to  get the
  4670.                     graph, you  can stop  your program by <Esc> key when you
  4671.                     see the window has been resized and then  enter the same
  4672.                     run command  again in  blind. So, you have better to put
  4673.                     your WINDOW command on the first line.
  4674.  
  4675.  
  4676.  
  4677.  
  4678.  
  4679.  
  4680.  
  4681.                                      Page 60
  4682.  
  4683.  
  4684.  
  4685.  
  4686.  
  4687.  
  4688.  
  4689.  
  4690.  
  4691.  
  4692.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  4693.  
  4694.  
  4695.           VIEWPORT:
  4696.           ________
  4697.                Syntax:
  4698.                     VIEWPORT rx1,ry1,rx2,ry2
  4699.  
  4700.                Description:
  4701.                          WINDOW lets you to borrow  the  working  area  of a
  4702.                     spreadsheet window.  VIEWPORT command  lets you put your
  4703.                     picture  anywhere  in  your   screen.   If   the  raster
  4704.                     parameters  are  0,0,0,0  then  the whole screen will be
  4705.                     used for graphic display. It is desirable if you want to
  4706.                     test  the  graph  on  medium  resolution and display the
  4707.                     final graph on low resolution.
  4708.  
  4709.                Examples:
  4710.                     VIEWPORT 0,0,0,0
  4711.                     VIEWPORT 0,0,350,120
  4712.  
  4713.  
  4714.           SCALE:
  4715.           _____
  4716.                Syntax:
  4717.                     SCALE xmin, ymin, xmax, ymax
  4718.  
  4719.                Description:
  4720.                          SCALE setup the scaling factors which  are used for
  4721.                     mapping Cartesian  coordinate data  to Raster coordinate
  4722.                     pixels.  xmin,ymin  specifies  the   left  bottom-corner
  4723.                     coordinate  and  xmax,ymax  the  right  top-corner.  You
  4724.                     should make the scale a little bit larger  than what you
  4725.                     want to leave some spaces for texts.
  4726.  
  4727.           CLEAR:
  4728.           _____
  4729.                Syntax:
  4730.                     CLEAR
  4731.  
  4732.                Description:
  4733.                          This command  clears the screen specified by WINDOW
  4734.                     or VIEWPORT commands.
  4735.  
  4736.           EXITGRAPH:
  4737.           _________
  4738.                Syntax:
  4739.                     EXITGRAPH
  4740.  
  4741.                Description:
  4742.                          WINDOW  and  VIEWPORT  commands   will  change  the
  4743.                     clipping area. EXITGRAPH resets the clipping area to the
  4744.                     current window and refreshes  it  (sometimes  your graph
  4745.                     may overwrite part of the current window).
  4746.  
  4747.  
  4748.  
  4749.  
  4750.  
  4751.  
  4752.  
  4753.                                      Page 61
  4754.  
  4755.  
  4756.  
  4757.  
  4758.  
  4759.  
  4760.  
  4761.  
  4762.  
  4763.  
  4764.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  4765.  
  4766.      Line/Dot commands:
  4767.      _________________
  4768.           Each line  posseses some  attributes. It  has color, width and its
  4769.      type. A line can be a solid, or broken line. This is the type of a line
  4770.      and there are 6 line types defined.
  4771.           A dot  has color and width. Instead of dot, sometimes you may want
  4772.      to display your data  using  markers.  There  are  6  different markers
  4773.      defined in SHEET BASIC graphic commands.
  4774.           SHEET BASIC  is part  of the  spreadsheet SHEET. You may have your
  4775.      data stored in the spreadsheet. There are two special commands  to plot
  4776.      data stored in cells. They are PLOT DATA and SPLINE.
  4777.  
  4778.           ATTRIBUTE:
  4779.           _________
  4780.                Syntax
  4781.                     ATTRIBUTE color#,width
  4782.  
  4783.                Description:
  4784.                          ATTRIBUTE  command  changes  the color and width of
  4785.                     subsequent graphic  commands.  The  default  color  is 2
  4786.                     which is red and the default width is 1.
  4787.  
  4788.           LINE:
  4789.           ____
  4790.                Syntax:
  4791.                     LINE x1,y1,x2,y2[,linetype]
  4792.  
  4793.                Description:
  4794.                          This command  draws a line from (x1,y1) to (x2,y2).
  4795.                     If no type specified, it is  supposed to  be solid line.
  4796.                     The parameter type is a number ranging from 1 to 6.
  4797.                          linetype:
  4798.                               1:   solid line
  4799.                               2:   long dashes
  4800.                               3:   dots
  4801.                               4:   dash-dots
  4802.                               5:   dashes
  4803.                               6:   dash-dot-dot
  4804.  
  4805.           LINE_TO:
  4806.           _______
  4807.                Syntax:
  4808.                     LINE_TO x1,y1[,type]
  4809.  
  4810.                Description:
  4811.                          This  command   draws  a  line  from  the  previous
  4812.                     position  to  (x1,y1).   The   last   line/dot  commands
  4813.                     specified the previous position. If the program is newly
  4814.                     executed, the previous position is (0,0).
  4815.  
  4816.  
  4817.  
  4818.  
  4819.  
  4820.  
  4821.  
  4822.  
  4823.  
  4824.  
  4825.                                      Page 62
  4826.  
  4827.  
  4828.  
  4829.  
  4830.  
  4831.  
  4832.  
  4833.  
  4834.  
  4835.  
  4836.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  4837.  
  4838.           PLOT:
  4839.           ____
  4840.                Syntax:
  4841.                     PLOT x,y[,marker#]
  4842.  
  4843.                Description:
  4844.                          If no marker number  specified,  PLOT  command will
  4845.                     draw a dot on the position (x,y). The markers chosen for
  4846.                     SHEET BASIC are model after Lotus 123.
  4847.                          MARKER:
  4848.                               1:   square
  4849.                               2:   +
  4850.                               3:   diamond
  4851.                               4:   up-triangle
  4852.                               5:   x
  4853.                               6:   down-triangle
  4854.  
  4855.           PLOT DATA:
  4856.           _________
  4857.                Syntax:
  4858.                     PLOT DATA xrange, yrange[,marker#, linetype]
  4859.  
  4860.                Description:
  4861.                          The data are stored  in the  spreadsheet. PLOT DATA
  4862.                     accesses x,y pairs from the xrange and yrange specified.
  4863.                     It will plot data from the first row to the  last row in
  4864.                     the range.  Please refers  to PLOT for marker number and
  4865.                     LINE for linetype. NOTE: if your  data are  quite dense,
  4866.                     the linetype other than 1 may not break the line the way
  4867.                     you specified.
  4868.  
  4869.           SPLINE
  4870.           ______
  4871.                Syntax:
  4872.                     SPLINE xrange, yrange,increment
  4873.  
  4874.                Description:
  4875.                          Given n points (knots), mathematicians can  find n-
  4876.                     1 different  cubic polynomials  that pass  through the n
  4877.                       _________
  4878.                     points. This curve  generated  by  those  polynomials is
  4879.                     called  spline-curve.  It  is  a smooth curve and it may
  4880.                     represent the  data  more  closely  than  connecting the
  4881.                     points with  lines. Increment should be smaller than any
  4882.                     subinterval of the n  points. NOTE:  To use  SPLINE, you
  4883.                                                   NOTE:  To use  SPLINE, you
  4884.                     must provide at least 4 points.
  4885.                     must provide at least 4 points.
  4886.            
  4887.  
  4888.  
  4889.  
  4890.  
  4891.  
  4892.  
  4893.  
  4894.  
  4895.  
  4896.  
  4897.  
  4898.  
  4899.  
  4900.                                      Page 63
  4901.  
  4902.  
  4903.  
  4904.  
  4905.  
  4906.  
  4907.  
  4908.  
  4909.  
  4910.  
  4911.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  4912.  
  4913.      Turtlegraphics:
  4914.      ______________
  4915.           Turtlegraphics is quite interesting. I add these commands just for
  4916.      fun. Only three commands are provided though.
  4917.  
  4918.           FORWARD:
  4919.           _______
  4920.                Syntax:
  4921.                     FORWARD distance
  4922.  
  4923.                Description:
  4924.                          FORWARD command in LOGO  uses pixel  as measurement
  4925.                     for  distance.   SHEET  BASIC  uses  the  scale  factors
  4926.                     specified by SCALE  as  measurement  for  distance. This
  4927.                     command moves the drawing pen specified by the parameter
  4928.                     distance. Distance can be  negative  which  make FORWARD
  4929.                     acts as BACK in LOGO.
  4930.  
  4931.                Example:
  4932.                     FORWARD 5.2
  4933.  
  4934.           TURN, TURN_TO:
  4935.           ____  _______
  4936.                Syntax:
  4937.                     TURN degree
  4938.                     TURN_TO degree
  4939.  
  4940.                Description:
  4941.                          They  are  the  only  commands in SHEET BASIC using
  4942.                     degrees instead  of radians.  Degree 0  points to North.
  4943.                     East is  90 degree,  South is  180 and West is 270. TURN
  4944.                     turns the  active  turtle  by  the  amount  specified in
  4945.                     rotation.  TURN  is  similar  to  LEFT  if the degree is
  4946.                     positive and RIGHT if the degree is negative. TURN_TO is
  4947.                     similar to  SETHEADING in LOGO, which sets the direction
  4948.                     of the active turtle to a specified angle.
  4949.  
  4950.  
  4951.  
  4952.  
  4953.  
  4954.  
  4955.  
  4956.  
  4957.  
  4958.  
  4959.  
  4960.  
  4961.  
  4962.  
  4963.  
  4964.  
  4965.  
  4966.  
  4967.  
  4968.  
  4969.  
  4970.  
  4971.                                      Page 64
  4972.  
  4973.  
  4974.  
  4975.  
  4976.  
  4977.  
  4978.  
  4979.  
  4980.  
  4981.  
  4982.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  4983.  
  4984.      Axis command:
  4985.      ____________
  4986.           It is easy to draw the  x-axis and  y-axis by  using LINE command,
  4987.      but you  may also want to know where x=3 on the x-axis. MARKX and MARKY
  4988.      commands help you to mark your axes with measurement. LABELX and LABELY
  4989.      let you add the number 3 under the mark.
  4990.  
  4991.           MARKX/MARKY:
  4992.           ___________
  4993.                Syntax:
  4994.                     MARKX y_origin, xmin, xmax, xinc, xstep
  4995.                     MARKY x_origin, ymin, ymax, yinc, ystep
  4996.  
  4997.                Description:
  4998.                          An example  may help  me to explain better. Suppose
  4999.                     that you are drawing an x-y  graph for  your income from
  5000.                     1970  to  1988  and  your  income  ranges from 12,000 to
  5001.                     40,000.
  5002.                               SCALE 1969, 0, 1989, 45000
  5003.                     Making the x-axis one year larger on both sides give you
  5004.                     some blank  spaces. You do not care about amount smaller
  5005.                     than 12,000. The following command draws the x-axis.
  5006.                               LINE 1969,12000,1989,12000
  5007.                     Your y_origin starts from 12000. xmin  is 1970  and xmax
  5008.                     is 1988.  You want  to mark  each year and have a bigger
  5009.                     mark on each five year. Here is the command:
  5010.                               MARKX 12000,1970,1988,1,5
  5011.                     MARKY works similarly.
  5012.  
  5013.                     NOTE: xstep should be a multiple of xinc.
  5014.  
  5015.           LABELX/LABELY:
  5016.           _____________
  5017.                Syntax:
  5018.                     LABELX y_origin, xmin, xmax, xinc, format
  5019.                     LABELY x_origin, ymin, ymax, yinc, format
  5020.  
  5021.                Description:
  5022.                          I am using the same example on MARKX. Now, you want
  5023.                     to add  the year 1970 to 1988 on your graph. The command
  5024.                     to do this is:
  5025.                               LABELX 12000,1970,1988,1,"f0"
  5026.                     You may find some  of the  numbers are  overlapped. Then
  5027.                     you should adjust xinc.
  5028.  
  5029.                     Format is a string that specified what kind of format we
  5030.                     are going to use  for displaying  the labels. Currently,
  5031.                     there are  two formats  supported by  LABELX and LABELY.
  5032.                     They are FIXED and SCIENTIFIC. The string starts with an
  5033.                     f or  F means  the labels  are FIXED  number. The number
  5034.                     following f/F is the decimal place.  A scientific format
  5035.                     starts  with  an  s/S.  The  format string ("f0") on the
  5036.                     example means that we are displaying integers.
  5037.  
  5038.  
  5039.  
  5040.  
  5041.  
  5042.                                      Page 65
  5043.  
  5044.  
  5045.  
  5046.  
  5047.  
  5048.  
  5049.  
  5050.  
  5051.  
  5052.  
  5053.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  5054.  
  5055.      Text command:
  5056.      ____________
  5057.  
  5058.           PTEXT:
  5059.           _____
  5060.                Syntax:
  5061.                     PTEXT x,y,string[,color, effects, rotation, height]
  5062.  
  5063.                Description:
  5064.                          PTEXT plots string on the location (x,y). There are
  5065.                     some special effects:
  5066.                          1:   bold face
  5067.                          2:   light
  5068.                          4:   italic
  5069.                          8:   underline
  5070.                          16:  outline
  5071.                          32:  shadowed
  5072.                     If you  want to  use more  than one special effects, you
  5073.                     can do that by adding the  number for  each effects. For
  5074.                     example, if  you want  to plot the string with bold face
  5075.                     and underline, you should use 9 (1+8) for the effects.
  5076.  
  5077.                     Rotation  changes  the  direction  the  characters being
  5078.                     displayed.
  5079.                          0:        East
  5080.                          900:      North
  5081.                          1800:     West
  5082.                          2700:     South
  5083.  
  5084.                     Height of  a font  may be  changed but you may not get a
  5085.                     good result. The following  height  numbers  provide the
  5086.                     best result for small and normal fonts.
  5087.                          Color monitor:
  5088.                               small font:    4
  5089.                               normal font:   6
  5090.                          Monochrome monitor:
  5091.                               small font:    6
  5092.                               normal font:   13
  5093.  
  5094.  
  5095.  
  5096.  
  5097.  
  5098.  
  5099.  
  5100.  
  5101.  
  5102.  
  5103.  
  5104.  
  5105.  
  5106.  
  5107.  
  5108.  
  5109.  
  5110.  
  5111.  
  5112.                                      Page 66
  5113.  
  5114.  
  5115.  
  5116.  
  5117.  
  5118.  
  5119.  
  5120.  
  5121.  
  5122.  
  5123.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  5124.  
  5125.      Miscellaneous:
  5126.      _____________
  5127.  
  5128.  
  5129.           MOUSE_POS:
  5130.           _________
  5131.                Syntax:
  5132.                     MOUSE_POS x,y
  5133.  
  5134.                Description:
  5135.                          x,y  should   be  variables   or  cell  references.
  5136.                     MOUSE_POS will wait for you to press the  left button on
  5137.                     your  mouse.  If  your  mouse cursor is within the block
  5138.                     specified by WINDOW or  VIEWPORT, then  the Cartesian of
  5139.                     the mouse  cursor will  be stored on x,y. Otherwise, the
  5140.                     Raster coordinate is stored on x,y.
  5141.                          This command  is useful  for finding  the value for
  5142.                     WINDOW,  VIEWPORT  or  PTEXT.  It is also useful to find
  5143.                     some data points from your graph.
  5144.  
  5145.                Hints:
  5146.                          Mouse click response time varies not  in a constant
  5147.                     way (refer  to problems part). You may better add a WAIT
  5148.                                                                         ____
  5149.                     1 statement after the MOUSE_POS. So, user can  press the
  5150.                     _
  5151.                     button  a  little  bit  longer  without causing problem.
  5152.                     Also, MOUSE_POS will keep  polling until  you press your
  5153.                     mouse  button.  It  means  your  system is suspended for
  5154.                     mouse click. You cannot break its  operation by pressing
  5155.                     <Esc>. You  have better  add an ALERT or MESSAGE telling
  5156.                     user to press the mouse button.
  5157.  
  5158.  
  5159.  
  5160.  
  5161.  
  5162.  
  5163.  
  5164.  
  5165.  
  5166.  
  5167.  
  5168.  
  5169.  
  5170.  
  5171.  
  5172.  
  5173.  
  5174.  
  5175.  
  5176.  
  5177.  
  5178.  
  5179.  
  5180.  
  5181.  
  5182.  
  5183.  
  5184.                                      Page 67
  5185.  
  5186.  
  5187.  
  5188.  
  5189.  
  5190.  
  5191.  
  5192.  
  5193.  
  5194.  
  5195.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  5196.  
  5197.                             Tips on using SHEET BASIC
  5198.      Interrupt:
  5199.      Interrupt
  5200.                You can stop your BASIC program by pressing <Esc> key.
  5201.  
  5202.      Using previous row format:
  5203.      Using previous row format
  5204.                If  your  BASIC  program  generates  a  lot  of  data  to the
  5205.           worksheet,  you  should  choose  "Using previous format" from menu
  5206.           item "Options" to non.  It will  speed up  a little  of your BASIC
  5207.           program.
  5208.  
  5209.      Error:
  5210.      Error
  5211.                When the BASIC interpreter encounters error, it will tell you
  5212.           what is wrong and where the offending code is. You  can use  F2 to
  5213.           edit that  line and re-run it again. If your offending cell is for
  5214.           example G12, instead of re-run it,  you  can  use  "@goto  g12" to
  5215.           continue your program. It may save you some time.
  5216.  
  5217.      Multiple statements:
  5218.      Multiple statements
  5219.                You  can  enter  more  than  one  statement  in  a cell. Each
  5220.           statement must be separated by colon. Entering multiple statements
  5221.           in  one  cell  will  save  some  memory,  but don't enter too many
  5222.           because your editing buffer can hold 250 characters only.
  5223.  
  5224.      Garbled screen:
  5225.      Garbled screen
  5226.                If you output some data to your monitor,  your current screen
  5227.           display will  be garbled.  In case  you forget to save your screen
  5228.           before you print, you  can rebuild  your display  by the following
  5229.           steps:
  5230.                -    Select the menu bar and choose "About SHEET"
  5231.                -    Press return when the dialog shown up.
  5232.                -    If the  number of  windows being  opened is less than 4,
  5233.                     you can choose "New" to open up a new worksheet and then
  5234.                     close it.
  5235.                -    If the  number is  4, then you must move your window out
  5236.                     of the screen and move it back.
  5237.  
  5238.      Adjust:
  5239.      Adjust
  5240.                When I wrote the first SHEET  BASIC  program,  I  felt  it is
  5241.           clumsy  to  enter  "!"  at  the  beginning of each statement and I
  5242.           forgot to enter "!" in some cells. If you have  the same problems,
  5243.           you can use the following technique to enter BASIC statement.
  5244.                As we know, each BASIC statement starts with an alpha letter.
  5245.           SHEET will treat any  cell entry  starts with  an alpha  letter as
  5246.           TEXT string.  You can  enter your  BASIC codes  as text string and
  5247.           then adjust them to BASIC statements. The steps to adjust codes:
  5248.                -    select blocks to cover the desired cells
  5249.                -    Press <Control A> and choose "BASIC  (!)" to  adjust the
  5250.                     text string to BASIC statements.
  5251.  
  5252.  
  5253.  
  5254.  
  5255.  
  5256.  
  5257.  
  5258.                                      Page 68
  5259.  
  5260.  
  5261.  
  5262.  
  5263.  
  5264.  
  5265.  
  5266.  
  5267.  
  5268.  
  5269.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  5270.  
  5271.                           Appendix A BUILT-IN FUNCTIONS
  5272.                           _____________________________
  5273.                                                        
  5274.  
  5275.      Math:
  5276.      ____
  5277.           General functions:
  5278.                ABS(x):   Absolute function of x
  5279.                INT(x):   Integer part of x (e.g. +int(12.4) = 12)
  5280.                FRAC(x):  Fraction part of x (e.g. +frac(12.4) = 0.4)
  5281.                FACT(x):  Factorial of x. X < 34
  5282.                SQR(x):   Square function of x
  5283.                SQRT(x):  Square root of x
  5284.  
  5285.           Trigo & logarithm functions:
  5286.                SIN(x):   Sine function of x. X is measured in radian
  5287.                COS(x):   Cosine function of x.
  5288.                TAN(x):   Tangent function of x.
  5289.                ASIN(x):  Arc sine function of x
  5290.                ACOS(x):  Arc cosine function of x
  5291.                ATAN(x):  Arc tangent of x
  5292.                LOG(x):   Logarithm base 10
  5293.                LN(x):    Logarithm base e
  5294.                EXP(x):   Exponent of x
  5295.                RAD_DEG(x): Radian to degree
  5296.                DEG_RAD(x): Degree to radian
  5297.  
  5298.           DATE functions:
  5299.                DATE(mm,dd,yy): Function for calculating Julian days.
  5300.                DAY(x):   Day of x. X is Julian day
  5301.                MONTH(x): Month of x
  5302.                YEAR(x):  Year of x
  5303.                NOTE: 1.  You  can  use  the  following  formula  to find the
  5304.                          weekday of the date:
  5305.                                (date(mm,dd,yy)+1) mod 7
  5306.                          0 if Sunday, 1 if Monday and so on.
  5307.                      2.  You can  use  the  following  formula  to  find the
  5308.                          number of days on a specific month.
  5309.                          case 1: mm<12       date(mm+1,1,yy)-date(mm,1,yy)
  5310.                          case 2: mm=12       date(1,1,yy+1)-date(mm,1,yy)
  5311.  
  5312.           Matrix functions:
  5313.                     A matrix  in a  worksheet is a block embraced by "[" and
  5314.                "]". For example, to make A1..C3  as a  matrix, it  should be
  5315.                [A1..C3].  Versions  before  2.0 of SHEET restrict individual
  5316.                matrix size within 64K. This limit has been removed.
  5317.  
  5318.                     Matrix operators include *,+ and -. There is no priority
  5319.                for those  matrix operators.  Formula is calculated from left
  5320.                to right. Parenthesis can be used  to change  the calculation
  5321.                order.
  5322.  
  5323.                     There are  only two  matrix functions.  They are INVERSE
  5324.                and TRANSPOSE. Their arguments must be  a matrix  or a matrix
  5325.                operations grouped by parenthesis.
  5326.  
  5327.                     The sequence of activating matrix operations is:
  5328.  
  5329.                                      Page 69
  5330.  
  5331.  
  5332.  
  5333.  
  5334.  
  5335.  
  5336.  
  5337.  
  5338.  
  5339.  
  5340.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  5341.  
  5342.  
  5343.                          MATRIX(cell, matrix_operations)
  5344.  
  5345.                Cell:  The  cell  reference  of  the  MATRIX  is  the leading
  5346.                     location where matrix operations put their result.
  5347.                Matrix_operations: Matrix operations can  be matrix functions
  5348.                     or combination of matrix operators.
  5349.  
  5350.                For  example,  to  store  the  inverse  of matrix [a1..c3] in
  5351.                matrix  [d1..f3],  you  should  store  the  following formula
  5352.                somewhere:
  5353.                            +MATRIX(d1,inverse[a1..c3])
  5354.  
  5355.  
  5356.      Statistics:
  5357.      __________
  5358.           AVERAGE(  any  number  of  parameters  ):  Average  of parameters.
  5359.                     Parameters  can  be   a   single   cell   reference,  an
  5360.                     expression, a block of cells.
  5361.           MEDIAN( any number of parameters ): Median of parameters.
  5362.           STD( any number of parameters): Standard deviation of parameters.
  5363.           VAR( any number of parameters): Variance of parameters.
  5364.           SQR_SUM( any number of parameters): Square sum of parameters.
  5365.  
  5366.       eg. +AVERAGE(A1..F4,234,12+24.5,H2+34*sin(pi))
  5367.  
  5368.  
  5369.      Miscellaneous:
  5370.      _____________
  5371.           MAX(any number of parameters): Maximum value of parameters.
  5372.           MIN(any number of parameters): Minimum value of parameters.
  5373.           SUM(any number of parameters): Sum of all parameters.
  5374.           RAND: Random number between 0 and 1.
  5375.           IFF(condition,true_value, false_value): IF function
  5376.           ISEMPTY(cell): return 1 if cell is empty, otherwise 0
  5377.           TRUE: it is equal to 1
  5378.           FALSE: it is equal to 0
  5379.           ALERT     ALERT(default, "[icon#][text][exit]")
  5380.                     Uses the alert box to get user's response.
  5381.             icon#:
  5382.                0:   no icon
  5383.                1:   NOTE icon (!)
  5384.                2:   WAIT icon (?)
  5385.                3:   STOP icon (stop sign)
  5386.             text:
  5387.                text string  can be  up to 5 lines. Each line is separated by
  5388.                "|". You cannot have more than 40 characters per line. If you
  5389.                use  icon,  then  the  number  of  character per line must be
  5390.                lesser than  40. Keep  your character  per line  less than 30
  5391.                will be safe.
  5392.             exit:
  5393.                Up to 3 exit button can be defined. Each of them is separated
  5394.                by "|".
  5395.  
  5396.            eg.
  5397.                !A3=ALERT(1,"[1][This is a test|Wow][Ok|Cancel]")
  5398.  
  5399.                                      Page 70
  5400.  
  5401.  
  5402.  
  5403.  
  5404.  
  5405.  
  5406.  
  5407.  
  5408.  
  5409.  
  5410.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  5411.  
  5412.           COL_WIDTH COL_WIDTH(block)
  5413.                     Returns the  total column  widths that  holds the block.
  5414.                     For example, if column width of A is 8 and B is 12 and C
  5415.                     is 4:
  5416.                eg   COL_WIDTH(a1)            ==> 8
  5417.                     COL_WIDTH(b1..c1)        ==> 16
  5418.  
  5419.           LAST_ROW  LAST_ROW(cell,r)
  5420.                     Returns the value stores in the  last row  on the column
  5421.                     the cell  is. r  tells you  where the  last row is. r is
  5422.                     zero origin. For example, if the last row of column B is
  5423.                     12 and cell B12 has a value of 123.45:
  5424.                eg   LAST_ROW(b20,row)        ==> 123.45 and row=11
  5425.                     You can access the last cell by using B1[0,row]
  5426.  
  5427.           LAST_COL  LAST_COL(cell,c)
  5428.                     Returns the  value stores  in the last column on the row
  5429.                     the cell is. c tells you where the last column  is. c is
  5430.                     zero origin. For example, if the last column of row 4 is
  5431.                     H and cell H4 has a value of 456.77:
  5432.                eg   LAST_COL(a4,col)         ==> 456.77 and col=7
  5433.                     You can access the last cell by using a4[col,0]
  5434.  
  5435.           SEARCH    SEARCH(STRING,block,r,c)
  5436.                     A boolean function to find  out  whether  STRING  in the
  5437.                     block and  r,c tell  you where  the cell is. r and c are
  5438.                     zero origin so you can access the cell by using a1[c,r].
  5439.                     NOTE: the  comparison is  case insensitive and a cell of
  5440.                     the block  which has  a substring  includes STRING, then
  5441.                     the location  of that cell will be stored in r and c. If
  5442.                     search fails, r and c will not be changed.
  5443.                eg.  Assume    that    cell   A5$="What",b5$="is",c5$="your",
  5444.                     d5$="name?".
  5445.                     SEARCH("You",a5..d5,r,c) ==> 1  and r=4,  c=2. To access
  5446.                     the cell that holds a substring of "YOU", you should use
  5447.                     a1[c,r]$ (it is c5$ in this case).
  5448.  
  5449.  
  5450.      Finance:
  5451.      _______
  5452.           Future growth:
  5453.                GRATE(a time series data): Average growth rate.
  5454.                GBASE(a time series data): Adjusted base value
  5455.                GFUTURE(grate,gbase,  predict  time):  Future values based on
  5456.                     grate and gbase
  5457.  
  5458.                A time  series  data  is  data  being  collected  in  a fixed
  5459.                frequency of  time. They  may be  gathered yearly, quarterly,
  5460.                monthly or daily. For  example, you  income is  a time series
  5461.                data  that  is  increased  yearly. For a more detail example,
  5462.                refer to the example file "FG.SHT"
  5463.  
  5464.           Investment:
  5465.                INVEST_PV(final value, interest, compound  frequency, terms):
  5466.                     Present value of investment
  5467.  
  5468.                                      Page 71
  5469.  
  5470.  
  5471.  
  5472.  
  5473.  
  5474.  
  5475.  
  5476.  
  5477.  
  5478.  
  5479.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  5480.  
  5481.                INVEST_FV(present   value,   interest,   compound  frequency,
  5482.                     terms): Future value of investment
  5483.                INVEST_INTEREST(present   value,    final   value,   compound
  5484.                     frequency, terms):Compound interest of investment
  5485.                INVEST_TERM(present  value,  final  value, interest, compound
  5486.                     frequency): Terms of investment.
  5487.  
  5488.                Please  refer  to  the  file  "INVEST.SHT"  for  using  those
  5489.                functions.
  5490.  
  5491.           Loan:
  5492.                LOAN_PAY(amount  borrowed,  interest,total  terms,  number of
  5493.                     terms per year): Payment for each term.
  5494.                LOAN_AMOUNT(payment, interest, total terms,  terms per year):
  5495.                     Amount borrowed.
  5496.                LOAN_TERM(amount  borrowed,   payment,  interest,  terms  per
  5497.                     year): Total number of terms for loan. 
  5498.  
  5499.                Please  refer  to  the   file  "LOAN.SHT"   for  using  those
  5500.                functions.
  5501.  
  5502.           Withdraw:
  5503.                WDRAW_SAVE(amount  withdrawn,   interest,  terms,  terms  per
  5504.                     year): Initial Investment
  5505.                WDRAW_AMOUNT(amount saved, interest, terms,  terms per year):
  5506.                     Amount withdrawn.
  5507.                WDRAW_TERM(amount  saved,  amount  withdrawn, interest, terms
  5508.                     per year): Total terms
  5509.  
  5510.                Please refer  to  the  file  "WITHDRAW.SHT"  for  using those
  5511.                functions.
  5512.  
  5513.           Deposit:
  5514.                DEPOSIT_FV(amount,  interest,  total  terms, terms per year):
  5515.                     Final value for deposit
  5516.                DEPOSIT_AMOUNT(final value, interest, total  terms, terms per
  5517.                     year): Regular deposit
  5518.                DEPOSIT_TERM(amount, final  value, interest, terms per year):
  5519.                     Total number of terms.
  5520.  
  5521.                Please  refer  to  the  file  "DEPOSIT.SHT"  for  using those
  5522.                functions.
  5523.  
  5524.  
  5525.  
  5526.      String functions:
  5527.      _________________
  5528.           FILENAME$ FILENAME$ is a string variable that can only be modified
  5529.                     by file selector dialog box.
  5530.  
  5531.           BUF$      BUF$ is  a string  variable that  can be  changed by the
  5532.                     command INPUT only.
  5533.  
  5534.           MID$:     MID$(STRING,s,len)
  5535.                     Returns  a  substring  of  STRING,  starting from s with
  5536.  
  5537.                                      Page 72
  5538.  
  5539.  
  5540.  
  5541.  
  5542.  
  5543.  
  5544.  
  5545.  
  5546.  
  5547.  
  5548.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  5549.  
  5550.                     length len. If s is larger than the length of the string
  5551.                     STRING, then  a substring range error occur. If len+s is
  5552.                     larger than the length  of STRING,  then up  to the last
  5553.                     character will be returned.
  5554.                eg   MID$("12345678",4,3)     ==> "456"
  5555.                     MID$("12345678",14,3)    ==> substring range error
  5556.                     MID$("12345678",4,20)    ==> "45678"
  5557.  
  5558.           LEFT$:    LEFT$(STRING,len)
  5559.                     Returns  a  substring  of  STRING,  starting from 1 with
  5560.                     length len. If len is larger  than the  actual length of
  5561.                     STRING, the whole STRING will be returned.
  5562.                eg   LEFT$("12345678",4)      ==> "1234"
  5563.                     LEFT$("12345678",20)     ==> "12345678"
  5564.  
  5565.           RIGHT$:   RIGHT$(STRING,len)
  5566.                     Returns  a  substring  of  STRING,  from  the  far right
  5567.                     portion of STRING with length len. If len is larger than
  5568.                     the length of STRING, then substring range error occurs.
  5569.                eg.  RIGHT$("12345678",4)     ==> "5678"
  5570.                     RIGHT$("12345678",20)    ==> substring range error
  5571.  
  5572.           SPACE$:   SPACE$(num)
  5573.                     Returns a string with num of blank spaces. num must be a
  5574.                     positive integer.
  5575.                eg.  SPACE$(4)                ==> "    "
  5576.  
  5577.           CHR$:     CHR$(num)
  5578.                     Returns a string with  one character  whose ASCII number
  5579.                     is equal to num. num is in the range of 0 to 255.
  5580.                eg   CHR$(82)                 ==> "R"
  5581.  
  5582.           STR$:     STR$([FORMAT,]value)
  5583.                     Changes a  number value  to a  string equivalent to that
  5584.                     value. FORMAT is optional. It is a string which consists
  5585.                     of  three  part  --  width, format, decimal point. It is
  5586.                     equivalent to  return a  cell string  with column width,
  5587.                     format and decimal place.
  5588.                eg   STR$(1234.5)             ==> "1234.5"
  5589.                     STR$("12$2",1234.5)      ==> "    $1234.50"
  5590.  
  5591.           VAL:      VAL(STRING)
  5592.                     Returns the  value of  STRING. This  function will strip
  5593.                     off characters other than "E", digits, "+", "-"  and "."
  5594.                     first and do the translation later.
  5595.                eg   VAL("abc123.45")         ==> 123.45
  5596.                     VAL(".23e-2")            ==> 0.0023
  5597.                     VAL(".23ae-2")           ==> 0.0023
  5598.  
  5599.           LEN:      LEN(STRING)
  5600.                     Returns the  length of the STRING. An empty string has a
  5601.                     len of zero.
  5602.                eg   LEN("")                  ==> 0
  5603.                     LEN("123456")            ==> 6
  5604.  
  5605.                                      Page 73
  5606.  
  5607.  
  5608.  
  5609.  
  5610.  
  5611.  
  5612.  
  5613.  
  5614.  
  5615.  
  5616.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  5617.  
  5618.  
  5619.           POS:      POS(STRING1,STRING2,start)
  5620.                     Return the position of  any  character  of  STRING1 from
  5621.                     STRING2  beginning  from  start.  All  the  character of
  5622.                     STRING1 and STRING2 will be changed to upper case first.
  5623.                     A zero  will be returned if none has been found or start
  5624.                     is larger than the len of STRING2.
  5625.                eg   POS(" ", "What is this?",1)==> 5
  5626.                          A space in position 5.
  5627.                     POS("ts","What is this?",1)==>4
  5628.                          "t" is in position 4
  5629.                     POS("ts","What is this?",5)==>7
  5630.                          "s" is in position 7
  5631.                     POS("AT","What is this?",1)==>3
  5632.                          "A" is in position 3. Case insensitive.
  5633.                     POS(",-","What is this?",1)==>0
  5634.  
  5635.  
  5636.  
  5637.  
  5638.                              Appendix B CONTROL KEYS
  5639.                              _______________________
  5640.  
  5641.      Non-editing:
  5642.      ___________
  5643.           <Esc>               stops a running BASIC program.
  5644.           <Up arrow>          moves cell cursor one row up.
  5645.           <Down arrow>        moves cell cursor one row down.
  5646.           <Left arrow>        moves cell cursor one column left.
  5647.           <Right arrow>       moves cell cursor one column right.
  5648.           <Shift><arrows>     moves cell  cursor to  the direction specified
  5649.                               by the arrow key by page.
  5650.           <Return>            changes the editing direction to neutral.
  5651.           <Control><A>        adjusts  TEXT  string  to  BASIC statements or
  5652.                               text justification.
  5653.           <Control><N>        creates a new sheet
  5654.           <Control><L>        loads a sheet file
  5655.           <Control><S>        saves current spreadsheet
  5656.           <Control><P>        prints current spreadsheet
  5657.           <Control><Q>        exits to desktop
  5658.           <Control><I>        inserts a row or a column
  5659.           <Control><D>        deletes a row or a column
  5660.           <Control><R>        reformats cells
  5661.           <Control><E>        erases cells
  5662.           <Control><C>        copies cells
  5663.           <Control><M>        moves cells
  5664.           <Control><mouse click> defines the starting cell of a block
  5665.           <Shift><mouse click> defines the stopping cell of a block
  5666.           <Alternate><1>      switches to the first window
  5667.           <Alternate><2>      switches to the second window
  5668.           <Alternate><3>      switches to the third window
  5669.           <Alternate><4>      switches to the fourth window
  5670.           <Alternate><F>      refreshes the current window.
  5671.           <Alternate><C>      recalculates the spreadsheet by column
  5672.           <Alternate><N>      recalculates the spreadsheet by natural order
  5673.           <Alternate><R>      recalculates the spreadsheet by row
  5674.  
  5675.                                      Page 74
  5676.  
  5677.  
  5678.  
  5679.  
  5680.  
  5681.  
  5682.  
  5683.  
  5684.  
  5685.  
  5686.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  5687.  
  5688.           <F2>                modifies the current cell's content
  5689.           <F5>                Goto a specified cell.
  5690.  
  5691.      Editing:
  5692.      _______
  5693.           <Up arrow>          terminates and moves cell  cursor one  row up.
  5694.                               The editing direction changes to up direction.
  5695.           <Down arrow>        terminates and moves cell cursor one row down.
  5696.                               The editing direction changes to down.
  5697.           <Left arrow>        terminates and moves  cell  cursor  one column
  5698.                               left. The editing direction changes to left.
  5699.           <Right arrow>       terminates  and  moves  cell cursor one column
  5700.                               right. The editing direction changes to right.
  5701.           <Shift><Left arrow> moves editing cursor to left.
  5702.           <Shift><Right arrow> moves editing cursor to right.
  5703.           <Return>            terminates  and  moves  cell   cursor  to  the
  5704.                               direction specified by editing direction.
  5705.           <Mouse click>       if  the  mouse  cursor is within working area,
  5706.                               the coordinate of the cell under  mouse cursor
  5707.                               will be  inserted into  editing buffer; if the
  5708.                               mouse cursor is within  the editing  line, the
  5709.                               editing  cursor  will  move  to  the character
  5710.                               under the mouse cursor.
  5711.           <Control><mouse click> if the mouse cursor is within working area,
  5712.                               a comma  and the  coordinate of the cell under
  5713.                               mouse cursor  will  be  inserted  into editing
  5714.                               buffer.
  5715.           <Shift><mouse click> if the mouse cursor is within working area, a
  5716.                               through symbol ".." and the coordinate  of the
  5717.                               cell under  mouse cursor will be inserted into
  5718.                               editing buffer.
  5719.  
  5720.  
  5721.  
  5722.  
  5723.                         Appendix C Program specification:
  5724.                         ________________________________
  5725.  
  5726.                SHEET is written in  Mark Williams  C. The  accuracy for real
  5727.           number (double)  in Mark  Williams C is up to 17 digits (Lotus 123
  5728.           is up to 15 digits). The range  of  calculation  is      -1E-37 to
  5729.           1E+37.   Each spreadsheet can accomdate up to 2,549,745 (255*9999)
  5730.           cells and the spreadsheet is implemented  by using  Sparse Matrix.
  5731.           Any input to a cell will be tokenized before it is being inserted.
  5732.           This program support up to 4 windows. The BASIC interpreter can be
  5733.           used to handle graphics, string, and ASCII text files.
  5734.  
  5735.           Accuracy:
  5736.           Accuracy       up to 17 digits
  5737.           Range:
  5738.           Range          -1E-37 to  1E+37 (If you find 1e+37 in a cell, that
  5739.                          means the calculation for that cell is not correct)
  5740.           Arithmetic operators:
  5741.           Arithmetic operators
  5742.                          "+", "-", "*", "/", "^", MOD
  5743.           Logical operators:
  5744.           Logical operators:
  5745.                          AND, OR, NOT,  "=",  "<>",  ">",  "<",  ">=", "<=",
  5746.                          "=>", "=<"
  5747.           Built-In functions:
  5748.           Built-In functions
  5749.  
  5750.                                      Page 75
  5751.  
  5752.  
  5753.  
  5754.  
  5755.  
  5756.  
  5757.  
  5758.  
  5759.  
  5760.  
  5761.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  5762.  
  5763.                Math:     SIN, COS, TAN, ASIN, ACOS, ATAN, LOG, EXP, LN, ABS,
  5764.                          INT, FRAC, SQR, SQRT, DATE, FACT, RAD_DEG, DEG_RAD,
  5765.                          PI (constant)
  5766.                Statistics:
  5767.                          AVERAGE, MEDIAN, STD, VAR, SQR_SUM
  5768.                Miscellaneous:
  5769.                          MAX,  MIN,  SUM,  COUNT,  TODAY,  DAY, MONTH, YEAR,
  5770.                          TRUE, FALSE (TRUE and FALSE are constant, TRUE is 1
  5771.                          and  FALSE  is  0),  IFF, ISEMPTY, ALERT, LAST_ROW,
  5772.                          LAST_COL, SEARCH.
  5773.                Finance:  GRATE,   GBASE,   GFUTURE,   INVEST_PV,  INVEST_FV,
  5774.                          INVEST_INTEREST,       INVEST_TERM,       LOAN_PAY,
  5775.                          LOAN_AMOUNT,  LOAN_TERM,  WDRAW_SAVE, WDRAW_AMOUNT,
  5776.                          WDRAW_TERM,       DEPOSIT_FV,       DEPOSIT_AMOUNT,
  5777.                          DEPOSIT_TERM
  5778.                String:   MID$, CHR$, LEFT$, RIGHT$, SPACE$, STR$,  VAL, LEN,
  5779.                          ASC, FILENAME$(a string variable used for file item
  5780.                          selector) and BUF$(a string  variable  used  by the
  5781.                          command INPUT).
  5782.                Matrix:   MATRIX, TRANSPOSE, INVERSE, *, +, -
  5783.  
  5784.           Priority:
  5785.           Priority
  5786.                Lowest: - AND, OR
  5787.                        - "+", "-"
  5788.                        - "*", "/", "^", MOD
  5789.                        - number,  cell  reference,  variable, function call,
  5790.                          NOT, "+", "-" (unary operator)
  5791.                Highest:- Parenthesis
  5792.           Constants:
  5793.           Constants      PI(0.31415926535897932e+01), TODAY(Julian days when
  5794.                          you press TODAY), TRUE(1), FALSE(0).
  5795.           Cell reference:  A cell  can be  referred by using its spreadsheet
  5796.           Cell reference
  5797.                          coordinate (e.g. D1) If you add  a "$"  in front of
  5798.                          the row  number (in  this example 1) or in front of
  5799.                          the column letter (D) then you make it  an absolute
  5800.                          reference. If  you add  "$" at  the end of the cell
  5801.                          reference, then you are using it  as a  string. You
  5802.                          can use  a cell  as BASE  and move it vertically or
  5803.                          horizontally by  appending  two  numbers  which are
  5804.                          separated by comma and embraced by "[" and "]". The
  5805.                          first number increases  the  BASE  horizontally and
  5806.                          the  second  number  increases the BASE vertically.
  5807.                          For example A2[3,4]. You  can separate  A2 to [1,2]
  5808.                          (Column A  has a  value of  1, B  has 2 and so on).
  5809.                          A2[3,4] = [1,2]+[3,4]=[4,6]=D6.
  5810.           Variables:
  5811.           Variables      Up to 150 variables  can  be  defined.  This number
  5812.                          includes the  user defined function. It is intended
  5813.                          for BASIC usage. For the time being, you cannot use
  5814.                          those variables to hold any string.
  5815.  
  5816.  
  5817.  
  5818.                            Appendix D Lotus and SHEET
  5819.                            __________________________
  5820.  
  5821.  
  5822.  
  5823.                                      Page 76
  5824.  
  5825.  
  5826.  
  5827.  
  5828.  
  5829.  
  5830.  
  5831.  
  5832.  
  5833.  
  5834.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  5835.  
  5836.                In Lotus,  you must  add a  '@' symbol  before every function
  5837.           name. In SHEET, no special symbol  is required  to put  before the
  5838.           function name. However, if a function name is the first element of
  5839.           your formula, a '+' or '('  is required  to differentiate  it from
  5840.           TEXT.
  5841.                Lotus requires  you to  put #  symbol to  embrace the logical
  5842.           operators. For example , "+A1 #AND# A2". It  is invalid  in SHEET.
  5843.           Actually, you will get 2 bombs if you enter the above formula. You
  5844.           should avoid adding special character in  your formula.  The valid
  5845.           form is "+A1 AND A2".
  5846.                Lotus  @COUNT  function  will  count  any  cell  containing a
  5847.           numeric value or a label. SHEET will count only numeric value. For
  5848.           example,
  5849.                     A
  5850.                     _         B
  5851.                               _
  5852.                1
  5853.                _       12  This is a test
  5854.           @COUNT(A1..B1) will return 2 and COUNT(A1..B1) will return 1.
  5855.                Lotus @DATE function asks for arguments (YYYY,MM,DD) and DATE
  5856.           function in SHEET asks for (MM,DD,YY). The first  day of  @DATE is
  5857.           1-Jan-1900 while the first day of DATE is 1-Jan-4712 B.C.
  5858.                Here is a list of Lotus functions which have equivalent SHEET
  5859.           functions but using different names.
  5860.  
  5861.           @FV(amount,interest,terms) = DEPOSIT_FV(amount,interest,terms,1)
  5862.           @RATE(fv,pv,term) = INVEST_INTEREST(pv,fv,12,term*12)
  5863.           @TERM(pmt,int,fv) = DEPOSIT_TERM(pmt,fv,int,12)
  5864.           @PMT(amount,interest,terms) = LOAN_PAY(amount,interest,terms,12)
  5865.  
  5866.  
  5867.  
  5868.                             Appendix E Recalculation
  5869.                             ________________________
  5870.  
  5871.           Natural:
  5872.           Natural   Recalculates each cell  in  the  dependent  order. NOTE:
  5873.                     some spreadsheet programs use dependent list to find the
  5874.                     dependent order and they  can quickly  recalculate those
  5875.                     cells  being  affected.  SHEET  uses recursive method to
  5876.                     recalculates  cells.  The  effect  is  that,  it blindly
  5877.                     recalculate every  cell which contains formula and it is
  5878.                     slower than using dependent  list. The  positive side is
  5879.                     that, you have more memory to use than those spreadsheet
  5880.                     programs. This is a trade-off between speed and space.
  5881.           Row:
  5882.           Row:      Recalculate each row in the ascending order.
  5883.           Column:
  5884.           Column:   Recalculate each column in the ascending order.
  5885.                     
  5886.           Manual:
  5887.           Manual    The spreadsheet stops automatic  recalculation. User has
  5888.                     to press <ALT-N>, <ALT-R> or <ALT-C> for natural, row or
  5889.                     column   recalculation,   where   <ALT-N>   means  press
  5890.                     <Alternate> key with character key <N> simultaneously.
  5891.           Note:     It  is  no  longer  true  that  natural recalculation is
  5892.                     slower than row or column recalculation.
  5893.  
  5894.  
  5895.  
  5896.  
  5897.  
  5898.  
  5899.  
  5900.                                      Page 77
  5901.  
  5902.  
  5903.  
  5904.  
  5905.  
  5906.  
  5907.  
  5908.  
  5909.  
  5910.  
  5911.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  5912.  
  5913.  
  5914.                              Appendix F FILE FORMAT
  5915.                              ______________________
  5916.  
  5917.      Header for SHT:
  5918.      Header for SHT
  5919.           -    270 bytes reserved data.
  5920.             Currently, there are a few bytes have been used.
  5921.                -    2 bytes for file version number, current version is 1.4
  5922.                -    1 bytes for screen type when the file saved. 1 for color
  5923.                     monitor and 0 for monochrome monitor.
  5924.                -    2 bytes for maximum row number.
  5925.           -    40  bytes  for  window  title.  (39  characters  with  a null
  5926.                character)
  5927.           -    2 bytes: check-sum of the window  title to  make sure  we are
  5928.                handling the right work sheet.
  5929.           -    256 bytes for width of each columns
  5930.           -    2 bytes for window type (It is useless)
  5931.           -    8 bytes for current window size
  5932.           -    4 bytes for working area top row, top column
  5933.           -    4 bytes for current cell cursor address
  5934.           -    2 bytes for current recalculation mode
  5935.  
  5936.      Cell contents for SHT format:
  5937.      Cell contents for SHT format
  5938.           -    1 bytes for cell type (use this byte with 0x23 to do bit-wise
  5939.                     and. If it is not 0, then it is NUMBER).
  5940.           -    2 bytes for length
  5941.             - IF NUMBER:
  5942.                2 bytes for row #, 1 byte for column #.
  5943.                2 bytes for attribute and 1 byte for decimal place
  5944.                8 bytes for calculating result.
  5945.             - IF NOT NUMBER (it may be TEXT or STATEMENT, its  decimal place
  5946.                     and calculating result are not needed)
  5947.                2 bytes for row#, 1 byte for column #.
  5948.                2 bytes for attribute (it may be blank cell)
  5949.           -    IF length <> 0, length bytes of tokens.
  5950.           -    The last cell type and length are 0 and 0.
  5951.  
  5952.      Header for PRT:
  5953.      Header for PRT
  5954.           - 4 bytes holding "PART"
  5955.  
  5956.      Cell contents for PART format: 
  5957.      Cell contents for PART format
  5958.           -    4 bytes for cell row, column
  5959.           -    2 bytes for display attribute
  5960.           -    2 bytes for decimal place
  5961.           -    2 bytes for tokens length
  5962.           -    8 bytes for calculated result
  5963.           -    tokens length bytes of actual tokens
  5964.  
  5965.  
  5966.  
  5967.                                Appendix G Problems
  5968.                                ___________________
  5969.  
  5970.           A user told me his cell cursor keep flashing
  5971.             ans:    It won't happen very often. It seems it happens when the
  5972.                     system is newly bootup and you load SHEET right away. In
  5973.  
  5974.                                      Page 78
  5975.  
  5976.  
  5977.  
  5978.  
  5979.  
  5980.  
  5981.  
  5982.  
  5983.  
  5984.  
  5985.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  5986.  
  5987.                     SHEET, you  can locate  the cell  cursor by mouse click.
  5988.                     You can also select a  block  by  prolonging  your mouse
  5989.                     click (drag). When you press your mouse to move the cell
  5990.                     cursor, SHEET  first  moves  your  cell  cursor  to that
  5991.                     position  and  inverts  the  color  of  that cell. Mouse
  5992.                     response time seems a  lot  faster  when  the  system is
  5993.                     newly bootup.  Because of  the fast response time, SHEET
  5994.                     thinks you are  still  pressing  your  mouse  button. It
  5995.                     thinks you  are trying  to select  a block then. That is
  5996.                     the reason why your cell cursor on and off. In  case you
  5997.                     have this  problem, you  should choose  some of the help
  5998.                     dialogs. 4 or 5 of  them  should  slow  down  your mouse
  5999.                     response  time.  Another  method  found  by  a  user  is
  6000.                     provided here. After the  system is  booted, you  type a
  6001.                     key and then load your SHEET program.
  6002.  
  6003.           Why some of my input characters are being truncated?
  6004.              ans:   For  versions  before  2.0,  if  you  type  any  illegal
  6005.                     character in your formula,  you will  be bombed  out and
  6006.                     you  must  reboot  your  system  to  use SHEET. This new
  6007.                     version of SHEET  prevents  this  problem  but  the rest
  6008.                     characters after the illegal character will be truncated
  6009.                     and a "#" symbol will be added at the end of the illegal
  6010.                     formula. You should rewrite your formula.
  6011.  
  6012.  
  6013.  
  6014.  
  6015.  
  6016.  
  6017.  
  6018.  
  6019.  
  6020.  
  6021.  
  6022.  
  6023.  
  6024.  
  6025.  
  6026.  
  6027.  
  6028.  
  6029.  
  6030.  
  6031.  
  6032.  
  6033.  
  6034.  
  6035.  
  6036.  
  6037.  
  6038.  
  6039.  
  6040.  
  6041.  
  6042.                                      Page 79
  6043.  
  6044.  
  6045.  
  6046.  
  6047.  
  6048.  
  6049.  
  6050.  
  6051.  
  6052.  
  6053.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  6054.  
  6055.                                 Biorthym program
  6056.                                 ________________
  6057.                                                 
  6058.  
  6059.           A   German   doctor   found   that  our  emotional,  physical  and
  6060.      intellectual  conditions  change   in   sine   curves   with  different
  6061.      frequencies. Emotional condition changes in 23 days per cycle, physical
  6062.      28 days, and intellectual 33 days. They are called biorthym.
  6063.  
  6064.           The following SHEET BASIC program uses the data  found to generate
  6065.      the biorthym  curves for you. You should enter your name in cell B1 and
  6066.      your birthday in B2 using +DATE(mm,dd,yy), then you  can run  it by the
  6067.      command "@run e1".
  6068.  
  6069.      E1    : !B3= TODAY
  6070.      E2    : !B4=B3-B2+1:START= DATE( MONTH( TODAY),1, YEAR( TODAY))-B2
  6071.      E3    : ! IF B3<0 THEN  MESSAGE "Date entry error": END 
  6072.      E4    : !EMOTION=START MOD 23
  6073.      E5    : !PHYSICAL=START MOD 28
  6074.      E6    : !INTELLECTUAL=START MOD 33
  6075.      E7    : ! WINDOW 1,0,11,417,199
  6076.      E8    : ! SCALE -4,-1.5,33,1.1
  6077.      E9    : ! CLEAR :EC=2*PI/23:PC=2*PI/28:IC=2*PI/33
  6078.      E10   : ! FOR X=1 TO 31
  6079.      E11   : !Z1=EMOTION*EC:EMOTION=EMOTION+1
  6080.      E12   : !Z2=PHYSICAL*PC:PHYSICAL=PHYSICAL+1
  6081.      E13   : !Z3=INTELLECTUAL*IC:INTELLECTUAL=INTELLECTUAL+1
  6082.      E14   : ! PLOT X, SIN(Z1),1: PLOT X, SIN(Z2),2: PLOT X, SIN(Z3),3
  6083.      E15   : ! NEXT X
  6084.      E16   : ! LINE 1,0,31,0
  6085.      E17   : ! LINE 1,-1,1,1
  6086.      E18   : ! MARKX 0,1,31,1
  6087.      E19   : ! MARKY 1,-1,1,0.1,0
  6088.      E20   : ! LABELX 0,2,30,2,"f0"
  6089.      E21   : ! LABELY 1,-1,1,0.1,"f1"
  6090.      E22   : ! PTEXT 11,-1.2,B1,1,1
  6091.      E23   : ! PLOT -2,-1.35,1: PTEXT -1,-1.4,"Emotional"
  6092.      E24   : ! PLOT 8,-1.35,2: PTEXT 9,-1.4,"Physical"
  6093.      E25   : ! PLOT 20,-1.35,3: PTEXT 21,-1.4,"Intellectual"
  6094.      E26   : ! EXITGRAPH 
  6095.      E27   : ! END 
  6096.  
  6097.      Explanations:
  6098.      E1:  Set the current date on cell B3.
  6099.      E2:  B4 holds the days of your life. Variable START holds the days from
  6100.           your birth to the first  day  of  current  month.  The  plus  1 in
  6101.           calculating  B4  means  that  your  first day is counted as 1. But
  6102.           biorthym calculates the first day as 0. (Sine curve starts  from 0
  6103.           to 2*PI).
  6104.      E3:  This is  unnecessary. I  just want  to show  you how  to display a
  6105.           message.
  6106.      E4:  Since our emotional condition changes in  a cycle  of 23  days, we
  6107.           can calculate  the condition  of the first day of current month by
  6108.           using the operator MOD.
  6109.      E5:  Similar to E4
  6110.      E6:  Similar to E4
  6111.  
  6112.                                      Page 80
  6113.  
  6114.  
  6115.  
  6116.  
  6117.  
  6118.  
  6119.  
  6120.  
  6121.  
  6122.  
  6123.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  6124.  
  6125.      E7:  Setup our graphic window
  6126.      E8:  Setup the scaling factor.  Making  the  scaling  factors  a little
  6127.           larger than  what they actually are will provide some blank spaces
  6128.           for texts.
  6129.      E9:  Clear  the  window  area.  EC  is  emotional  constant.  Emotional
  6130.           condition changes  in 23  days per cycle. Each cycle is 2*PI long.
  6131.           PC for physical condition and IC for intellectual condition.
  6132.      E10: A FOR loop to draw your graph. I  just assume  each month  have 31
  6133.           days. You may want to change 31 to its actual days.
  6134.      E11~E13:  Simple calculation for your conditions.
  6135.      E14: Plot emotional  condition with  marker 1,  physical with marker 2,
  6136.           and intellectual with marker 3
  6137.      E16~E17: Plot the x-axis and y-axis
  6138.      E18: Draw marks on x-axis
  6139.      E19: Draw marks on y-axis
  6140.      E20: Draw label on x-axis. It is integer.
  6141.      E21: Draw label on y-axis. It is real with 1 decimal place.
  6142.      E22: Plot your name on screen. (B1 holds your name)
  6143.      E23~E25: Plot texts showing the meaning for each marker.
  6144.      E26: Legal way to return to your current window
  6145.      E27: END program.
  6146.  
  6147.  
  6148.  
  6149.  
  6150.  
  6151.  
  6152.  
  6153.  
  6154.  
  6155.  
  6156.  
  6157.  
  6158.  
  6159.  
  6160.  
  6161.  
  6162.  
  6163.  
  6164.  
  6165.  
  6166.  
  6167.  
  6168.  
  6169.  
  6170.  
  6171.  
  6172.  
  6173.  
  6174.  
  6175.  
  6176.  
  6177.  
  6178.  
  6179.  
  6180.                                      Page 81
  6181.  
  6182.  
  6183.  
  6184.  
  6185.  
  6186.  
  6187.  
  6188.  
  6189.  
  6190.  
  6191.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  6192.  
  6193.                                 Calendar program
  6194.                                 ________________
  6195.  
  6196.                The file name of  this  program  is  "CAL.SHT".  This program
  6197.           generates a month calendar and leaves some spaces for your monthly
  6198.           activity. Here is the listing. To run it, enter "@run q1"
  6199.  
  6200.      Q1     :!MON=10:YR=88:IBM= FALSE
  6201.      Q2     :!WEEKDAY=( DATE(MON,1,YR)+1) MOD 7
  6202.      Q3     :! IF (MON<12) THEN TDAY= DATE(MON+1,1,YR)- DATE(MON,1,YR): ELSE
  6203.      TDAY= DATE(1,1,YR+1)- DATE(MON,1,YR)
  6204.      Q4     :! IF IBM THEN  GOSUB Q34: ELSE  GOSUB Q42
  6205.      Q5     :! ERASE A1..O64
  6206.      Q6     :!B3$="^Sun":D3$="^Mon":F3$="^Tue":H3$="^Wed"
  6207.      Q7     :!J3$="^Thu":L3$="^Fri":N3$="^Sat"
  6208.      Q8     :!LINES=(WEEKDAY+TDAY)/7
  6209.      Q9     :!LINES= INT(LINES)+( FRAC(LINES)>0)
  6210.      Q10    :!WIDTH=60/LINES
  6211.      Q11    :! FOR I=0 TO 62
  6212.      Q12    :! FOR J=0 TO 14 STEP 2:A2[J,I]$= CHR$(VERT): NEXT J
  6213.      Q13    :! NEXT I
  6214.      Q14    :! FOR I=0 TO 12
  6215.      Q15      :! IF  (I MOD  2)=0 THEN B2[I,0]$="\"+ CHR$(HOR):B4[I,0]$="\"+
  6216.      CHR$(HOR): ELSE B2[I,0]$="\"+ CHR$(MDOWN):B4[I,0]$="\"+ CHR$(PLUS)
  6217.      Q16    :! NEXT I
  6218.      Q17        :!A2$=  CHR$(TLEFT):O2$=  CHR$(TRIGHT):A4$= CHR$(PLEFT):O4$=
  6219.      CHR$(PRIGHT)
  6220.      Q18    :! FOR I=1 TO LINES
  6221.      Q19    :!L=I*WIDTH: COPY A4..O4,A4[0,L]
  6222.      Q20    :! NEXT I
  6223.      Q21    :! FOR J=0 TO 12 STEP 2:C64[J,0]$= CHR$(MUP): NEXT J
  6224.      Q22    :!A64$= CHR$(BLEFT):O64$= CHR$(BRIGHT)
  6225.      Q23    :!L=1:J=1:M=WEEKDAY*2
  6226.      Q24    :! FOR I=WEEKDAY TO WEEKDAY+TDAY+1
  6227.      Q25    :! IF (I MOD 7)=0 THEN L=L+WIDTH:M=0
  6228.      Q26    :!B4[M,L]=J:J=J+1:M=M+2: IF J=TDAY THEN I=42
  6229.      Q27    :! NEXT I
  6230.      Q28    :! SAVE  SCREEN : REDIRECT  TO "prn:"
  6231.      Q29    :! PRINT  SPACE$((80- LEN(V1$))/2);V1$: PRINT 
  6232.      Q30    :! PRINT_BLOCK A2..O64,4,76
  6233.      Q31    :! WAIT 2: RESTORE  SCREEN 
  6234.      Q32    :! END 
  6235.      Q34    :!MDOWN=194:MUP=193
  6236.      Q35    :!PLEFT=195:PRIGHT=180
  6237.      Q36    :!PLUS=197:VERT=179:HOR=196
  6238.      Q37    :!TLEFT=218:TRIGHT=191
  6239.      Q38    :!BLEFT=192:BRIGHT=217
  6240.      Q39    :! RETURN 
  6241.      Q42    :!MDOWN=45:MUP=45
  6242.      Q43    :!PLEFT=124:PRIGHT=124
  6243.      Q44    :!PLUS=43:VERT=124:HOR=45
  6244.      Q45    :!TLEFT=43:TRIGHT=43
  6245.      Q46    :!BLEFT=43:BRIGHT=43
  6246.      Q47    :! RETURN 
  6247.  
  6248.  
  6249.                                      Page 82
  6250.  
  6251.  
  6252.  
  6253.  
  6254.  
  6255.  
  6256.  
  6257.  
  6258.  
  6259.  
  6260.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  6261.  
  6262.      Explanation:
  6263.      Explanation
  6264.      Q1   Set the  month and  year we interest about in the variable mon and
  6265.           yr. You cannot use month and year for  the variable  names because
  6266.           they are names for built-in functions. IBM is TRUE if your printer
  6267.           can print the IBM graphic characters. If you change the  month and
  6268.           year in  cell Q1,  please change the string in cell V1 at the same
  6269.           time.
  6270.      Q2:  WEEKDAY stores the weekday of the first day of the  month. WEEKDAY
  6271.           is 0 if it is Sunday and 1 for Monday and so on.
  6272.      Q3:  TDAY is the total number of days in the specified month. It can be
  6273.           calculated easily by subtracting the first date of one month after
  6274.           mon from the first date of mon.
  6275.      Q4:  Initializes some constants depend on whether IBM is TRUE or FALSE.
  6276.      Q5:  Erase cells from A1 through O64
  6277.      Q6:  Row 2 and 4 holds the frame for the title of weekdays. Row 3 holds
  6278.           the title.
  6279.      Q8:  Normally, we need 4, 5 or 6 lines to hold  a monthly  calendar. To
  6280.           calculate how many lines are need for our current month, we can do
  6281.           it by adding the WEEKDAY and TDAY and divides it by 7.
  6282.      Q9:  This is a little  bit  tricky.  FRAC  is  a  function  returns the
  6283.           fractional part  of a numerical value. In this case, LINES from Q8
  6284.           is equal to 5.285714. FRAC(LINES) returns 0.285714. It  is greater
  6285.           than zero.  TRUE is  1 and  0 is  FALSE. (FRAC(LINES)>0) returns a
  6286.           value of 1 and the INT(LINES) returns a value of  5. So  we need 6
  6287.           lines to hold our current monthly calendar.
  6288.      Q10: The width  for each line is 60/LINES. Since the value of LINES can
  6289.           be 4,5 or 6. So, width is an integer.
  6290.      Q11~Q22 Fills the frame for  our  calendar.  TLEFT,  is  the  TOP left-
  6291.           corner, TRIGHT  is the TOP right-corner, BLEFT is the Bottom left-
  6292.           corner and BRIGHT is  the Bottom  right-corner. VER  is a vertical
  6293.           bar, HOR  is a  horizontal bar.  PLEFT is  a T character turns -90
  6294.           degree and PRIGHT is a T character turns 90 degrees. MDOWN is  a T
  6295.           character and  MUP is  a T  character turns  180 degrees. They are
  6296.           used to join lines in the edges. PLUS is a + character.
  6297.      Q23~Q27 Fills the Date into the calendar.
  6298.      Q28~Q31 prints the calendar to your printer.
  6299.      Q32: You should always end your program with END.
  6300.      Q34~Q39: Defines constants for IBM=TRUE
  6301.      Q42~Q47: Defines constants for IBM=FALSE
  6302.  
  6303.  
  6304.  
  6305.  
  6306.  
  6307.  
  6308.  
  6309.  
  6310.  
  6311.  
  6312.  
  6313.  
  6314.  
  6315.  
  6316.  
  6317.  
  6318.                                      Page 83
  6319.  
  6320.  
  6321.  
  6322.  
  6323.  
  6324.  
  6325.  
  6326.  
  6327.  
  6328.  
  6329.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  6330.  
  6331.  
  6332.                                       Roots
  6333.                                       _____
  6334.                                            
  6335.  
  6336.           ROOTS.SHT is  a sample  program which  finds roots  for any single
  6337.      variable functions.  There are some techniques which are not covered in
  6338.      other sample programs. You should study it even you have no interest in
  6339.      finding roots for a function.
  6340.  
  6341.      B1    : !XMIN=-5:YMIN=-5:XMAX=5:YMAX=100:ST=0.1:ERR=0.000001
  6342.      B2    : ! DEFINE F(X)=3*X*X-2
  6343.      B3            :   !   IF      ALERT(2,"[0][Which   resolution  you  are
  6344.      in?][Medium|High]")=2  THEN    WINDOW  0,0,20,639,399:  ELSE     WINDOW
  6345.      0,0,11,639,199
  6346.      B4    : ! SCALE XMIN,YMIN,XMAX,YMAX
  6347.      B5    : ! CLEAR 
  6348.      B6    : ! PLOT XMIN,F(XMIN)
  6349.      B7    : ! FOR X=XMIN TO XMAX STEP ST
  6350.      B8    : ! LINE_TO X,F(X)
  6351.      B9    : ! NEXT X
  6352.      B10   : ! LINE XMIN,0,XMAX,0: LINE 0,YMIN,0,YMAX
  6353.      B11   : !X= ALERT(1,"[0][Can you see any|root in your graph?][Yes|No]")
  6354.      B12    : ! IF X=2 THEN  MESSAGE "Change your minimum and|maximum values
  6355.      and try again": EXITGRAPH 
  6356.      B13   : ! IF X=2 THEN  END 
  6357.      B14   : ! MESSAGE "Locate mouse  cursor|to the  left of  a|root in your
  6358.      graph"
  6359.      B15   : ! MOUSE_POS AX,AY
  6360.      B16    :  ! MESSAGE "Locate mouse cursor|to the right of a|root in your
  6361.      graph"
  6362.      B17   : ! MOUSE_POS BX,BY
  6363.      B18   : ! LOOP 
  6364.      B19   : !AY=F(AX):BY=F(BX)
  6365.      B20   : ! EXIT  IF ( ABS(AY)<ERR OR  ABS(BY)<ERR)
  6366.      B21   : !HALF=(AX+BX)/2:HY=F(HALF)
  6367.      B22   : ! IF (AY*HY<0) THEN BX=HALF: ELSE AX=HALF
  6368.      B23   : ! ENDLOOP 
  6369.      B24   : ! IF  ABS(AY)<ERR THEN A1=AX: ELSE A1=BX
  6370.      B25   : ! EXITGRAPH 
  6371.      B26   : ! END 
  6372.  
  6373.           For solving different functions, you should adjust B1, B2.
  6374.  
  6375.      Explanations:
  6376.      Explanations
  6377.  
  6378.      B1:  min,ymin,xmax,ymax setup the scaling factors. ST is step value for
  6379.           plot the function. ERR is the error tolerance. If you want to have
  6380.           a more accurate result, you should make ERR smaller.
  6381.      B2:  The function we are  trying  to  find  roots  for.  Remember, each
  6382.           function definition should have its own cell
  6383.      B3:  Open  the  largest  window  on Medium or High resolution. Remember
  6384.           WINDOW 0 is the current window.  The rest  numbers are  the raster
  6385.           coordinate.
  6386.      B4:  Set the scaling factors.
  6387.      B5:  Clear our window
  6388.  
  6389.                                      Page 84
  6390.  
  6391.  
  6392.  
  6393.  
  6394.  
  6395.  
  6396.  
  6397.  
  6398.  
  6399.  
  6400.  SHEET User manual             By Chor-ming Lung                October 9, 1988
  6401.  
  6402.      B6:  Plot the first point
  6403.      B7:  Plot the rest of the graph.
  6404.      B10: Draw the x- and y-axes.
  6405.      B11: A root  on a  graph is  the place where it hits the x-axis. If you
  6406.           see the curve hits the x-axis, you should answer Yes.
  6407.      B12: If the curve does not hit x-axis, then  leave a  reminder for user
  6408.           to change  the plotting  range. If  you set up a large value for x
  6409.           range, and you still can't see the root, then the function defined
  6410.           may not have a root. You cannot use this program to find it.
  6411.      B13: EXITGRAPH  command  is  not  working  quite well. It does not like
  6412.           anything following  it. I  still don't  know why.  The END command
  6413.           should follow  EXITGRAPH, but there is a bug which force us to end
  6414.           the program this way.
  6415.      B14: If you see a root, you can use the mouse to locate the left handed
  6416.           side value  for the root. This message just reminds user to select
  6417.           the left handed side value for the root. You may need to hold your
  6418.           mouse a little longer that usual.
  6419.      B15: User input the left handed side value by pointing the mouse cursor
  6420.           to the  left of  the point  that hits  the x-axis,  and click your
  6421.           mouse button. You can point to anywhere on the left handed side of
  6422.           the root.
  6423.      B16~B17:We need the right handed  side  value.  The  program  should be
  6424.           stopped quite fast. If you see nothing happen for a long time, you
  6425.           should press the mouse button again.  If it  is still  waiting for
  6426.           mouse button, <Esc> key will not stop the program.
  6427.      B18: A loop using bi-section method to find the root of a function.
  6428.      B24: If we found the root, we put it in cell A1
  6429.      B25: Normal exit
  6430.      B26  End of the program.
  6431.  
  6432.  
  6433.  
  6434.  
  6435.  
  6436.  
  6437.  
  6438.  
  6439.  
  6440.  
  6441.  
  6442.  
  6443.  
  6444.  
  6445.  
  6446.  
  6447.  
  6448.  
  6449.  
  6450.  
  6451.  
  6452.  
  6453.  
  6454.  
  6455.  
  6456.  
  6457.                                      Page 85
  6458.  
  6459.  
  6460.  
  6461.  
  6462.  
  6463.